Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
Exploring SQL activity of new dashboard¶
See 2021-06-15.
>>> from lino import startup
>>> startup('lino_book.projects.noi1r.settings')
>>> from lino.api.doctest import *
During startup there were two SQL queries:
>>> show_sql_queries()
SELECT excerpts_excerpttype.id, excerpts_excerpttype.name, excerpts_excerpttype.build_method, excerpts_excerpttype.template, excerpts_excerpttype.attach_to_email, excerpts_excerpttype.email_template, excerpts_excerpttype.certifying, excerpts_excerpttype.remark, excerpts_excerpttype.body_template, excerpts_excerpttype.content_type_id, excerpts_excerpttype.primary, excerpts_excerpttype.backward_compat, excerpts_excerpttype.print_recipient, excerpts_excerpttype.print_directly, excerpts_excerpttype.shortcut, excerpts_excerpttype.name_de, excerpts_excerpttype.name_fr FROM excerpts_excerpttype ORDER BY excerpts_excerpttype.id ASC
SELECT django_content_type.id, django_content_type.app_label, django_content_type.model FROM django_content_type WHERE django_content_type.id = ...
SELECT django_content_type.id, django_content_type.app_label, django_content_type.model FROM django_content_type WHERE django_content_type.id = ...
Now we do a single request to Tickets
. And look at all the
SQL that poor Django must do in order to return a single row.
>>> reset_sql_queries()
>>> ses = rt.login('robin')
>>> test_client.force_login(ses.get_user())
>>> r = test_client.get('/')
>>> show_sql_summary()
================ =========== =======
table stmt_type count
---------------- ----------- -------
COMMIT 1
UNKNOWN 1
UPDATE 1
django_session SELECT 1
users_user SELECT 1
================ =========== =======
>>> reset_sql_queries()
>>> ses.show('system.Dashboard')
...
Quick links:
...
Hi, Robin Rood!
...
Nulla vel enim vel eros venenatis congue.[✓]22/05/2015 05:48 Welcome on board, Robin.
>>> show_sql_summary()
... # tickets_ticket & users_user queries are more then expected probably because of multiple tries when there's a connection error from elasticsearch's side.
...
============================ =========== =======
table stmt_type count
---------------------------- ----------- -------
accounting_journal SELECT 2
accounting_ledgerinfo SELECT 4
cal_event SELECT 10
cal_eventtype SELECT 1
cal_task SELECT 1
calview_dailyplannerrow SELECT 1
checkdata_message SELECT 1
comments_comment SELECT 22
contacts_company SELECT 5
contacts_partner SELECT 4
contacts_person SELECT 7
dashboard_widget SELECT 1
django_content_type SELECT 6
groups_group SELECT 23
nicknames_naming SELECT 2
notify_message SELECT 1
storage_deliverynote SELECT 1
subquery SELECT 1
subscriptions_subscription SELECT 1
system_siteconfig SELECT 1
tickets_ticket SELECT 38
trading_vatproductinvoice SELECT 2
users_user SELECT 72
working_session SELECT 46
============================ =========== =======
>>> show_sql_queries()
...
>> r = test_client.get(‘/api/system/Dashboard’) >> print(r)
>> r = demo_get(‘robin’,’api/tickets/Tickets’, fmt=’json’, limit=1) >> res = test_client.get(‘/api/tickets/Tickets?fmt=json&limit=1’) >> res = check_json_result(res) >> rmu(res.keys()) [‘count’, ‘rows’, ‘no_data_text’, ‘success’, ‘title’, ‘param_values’] >> len(res[‘rows’]) 1