Ok, I found the problem:

Apparently Django already executes the SQL-queries during the System check, 
which are needed to construct the Dash-app (in my case I used [Dash 
Cytoscape][1]).
And yeah, it was really my database that was to big and therefore causing 
the queries too take so much time.
Hence it was not PostGreSQL, that was causing the issue...

Thus my solution was to crack down the queries into more efficient requests.

However, I'm still puzzled why I experienced so ambivalent running times 
depending on which lines I uncommented.
I personally got the impression that the system checks seemed to be rather 
non-transparent.


**Furthermore:**
If you want to disable/skip the system checks or even the migration checks, 
then see this StackOverflow entry:
[A solution to system checks on Django server in DEBUG mode][2]


  [1]: https://dash.plotly.com/cytoscape
  [2]: 
https://stackoverflow.com/questions/41438593/skip-system-checks-on-django-server-in-debug-mode-in-pycharm

Oliver Küchler schrieb am Freitag, 30. Juli 2021 um 17:35:58 UTC+2:

> I further worked on the topic, since I really want to solve it.
> I figured out, that the SQL-queries are already performed during 
> "Performing system checks...". 
> Does that make sense?
> However, I still don't understand why it's taking so much time.
>
> For more details and also an minimal example see here:
> Question on StackOverFlow 
> <https://stackoverflow.com/questions/68446241/djangos-performing-system-checks-takes-ages-with-postgresql>
>
> Oliver Küchler schrieb am Dienstag, 27. Juli 2021 um 16:20:29 UTC+2:
>
>>
>> Hey guys,
>>
>> I have already opened a question on StackOverflow, but so far nobody was 
>> able to help me out (link: StackOverflow-Link 
>> <https://stackoverflow.com/questions/68446241/why-does-djangos-system-check-take-so-much-time-import-django-db-models-sql>).
>>  
>> So I thought I'd give it a try in this group. (And I'm also not sure, 
>> whether it's a bug or something else...)
>>
>> *My Problem:*
>>
>> So I set up a webpage/webapplication that is powered by Django. 
>> Previously I utilized a MySQL database as backend and everything worked out 
>> smooth, but then I tried to switch to *PostGreSQL*.
>>
>> When I now try to start the Django-server in the shell it keeps getting 
>> stuck when the system checks are performed... From there it takes a very 
>> long time (circa 7-8 minutes) with my computer using a lot of CPU until 
>> finally the server starts with no issues.
>>
>> If I run "python -v manage.py check", I can see that Django is getting 
>> stuck on 2 things:
>>
>>    1. import 'django.db.models.sql.compiler' # 
>> <_frozen_importlib_external.SourceFileLoader 
>>    object at 0x7ff640701890>
>>    2. import 'plotly.express' # <_frozen_importlib_external.SourceFileLoader 
>>    object at 0x7ff640744d50>
>>
>> Also I realized that the problem disappears if I comment out python files 
>> that use Dash.
>>
>> I tried to build a very simple app to catch the beginning of the error, 
>> but it's really hard to localize and I'm slowly going crazy... 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/94e542d9-e0ab-4944-96fe-f2ec4982ea75n%40googlegroups.com.

Reply via email to