PostgreSQL Django Query
От | Sachin Kumar |
---|---|
Тема | PostgreSQL Django Query |
Дата | |
Msg-id | CALg-PKD6g_aEA40kpqSLuUoJrZEZA3LWG=vY1+Eqrk5inqaaXQ@mail.gmail.com обсуждение исходный текст |
Список | pgsql-sql |
Hi All,
I am using Python Django and PostgreSQL to build our report app.
I am using below mention query to find some details. the query mention below is running fine in PostgreSQL command line and giving results in 2 sc for 2 million cards but when I am trying the same in Django application it is taking too much time and the web page is expired while running this query.
can anyone help how to make the query faster in Django
rows = M_Assign.objects.raw(''' select C.id,M."merchant_name",C."MERCHANT_ID",S."store_id" Owning_Store_ID ,S."store_name" Owning_Store_Name,F."franchisee_name" Owning_Group,C."ACCOUNT_NUMBER",C."STORE_ID",C."GIFT_LIST_REF" FROM vdaccount_card_assign C INNER JOIN vd_merchant_master M ON C."MERCHANT_ID"=M."merchant_id" AND C."MERCHANT_ID"='003561002966107' INNER JOIN vd_store_master S ON S."store_id"=C."GIFT_LIST_REF" OR C."GIFT_LIST_REF"='' INNER JOIN vd_franchisee F ON S."franchisee_id"=F."franchisee_id" ''')
--
Best Regards,
Sachin Kumar

I am using Python Django and PostgreSQL to build our report app.
I am using below mention query to find some details. the query mention below is running fine in PostgreSQL command line and giving results in 2 sc for 2 million cards but when I am trying the same in Django application it is taking too much time and the web page is expired while running this query.
can anyone help how to make the query faster in Django
rows = M_Assign.objects.raw(''' select C.id,M."merchant_name",C."MERCHANT_ID",S."store_id" Owning_Store_ID ,S."store_name" Owning_Store_Name,F."franchisee_name" Owning_Group,C."ACCOUNT_NUMBER",C."STORE_ID",C."GIFT_LIST_REF" FROM vdaccount_card_assign C INNER JOIN vd_merchant_master M ON C."MERCHANT_ID"=M."merchant_id" AND C."MERCHANT_ID"='003561002966107' INNER JOIN vd_store_master S ON S."store_id"=C."GIFT_LIST_REF" OR C."GIFT_LIST_REF"='' INNER JOIN vd_franchisee F ON S."franchisee_id"=F."franchisee_id" ''')
Best Regards,
Sachin Kumar

В списке pgsql-sql по дате отправления: