[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    PostgreSQL Django Query
From:       Sachin Kumar <sachinkumaras () gmail ! com>
Date:       2021-01-07 11:56:27
Message-ID: CALg-PKD6g_aEA40kpqSLuUoJrZEZA3LWG=vY1+Eqrk5inqaaXQ () mail ! gmail ! com
[Download RAW message or body]

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
<http://s.bl-1.com/h/dcktcHRZ?url=http://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

[Attachment #3 (text/html)]

<div dir="ltr"><span \
style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">Hi \
All,</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><span \
style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">I \
am using Python Django and PostgreSQL to build our report app.</span><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><span \
style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">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.</span><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><span \
style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">can \
anyone help how to make the query faster in Django </span><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><br \
style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap"><span \
style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">rows \
= M_Assign.objects.raw(&#39;&#39;&#39; select </span><a \
href="http://s.bl-1.com/h/dcktcHRZ?url=http://c.id/" target="_blank" rel="noopener \
noreferrer" style="box-sizing:border-box;background-image:initial;background-position:0px \
0px;background-size:initial;background-repeat:initial;background-origin:initial;backgr \
ound-clip:initial;color:rgb(58,109,153);text-decoration-line:none;font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">C.id</a><span \
style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;w \
hite-space:pre-wrap">,M.&quot;merchant_name&quot;,C.&quot;MERCHANT_ID&quot;,S.&quot;store_id&quot; \
Owning_Store_ID ,S.&quot;store_name&quot; \
Owning_Store_Name,F.&quot;franchisee_name&quot; \
Owning_Group,C.&quot;ACCOUNT_NUMBER&quot;,C.&quot;STORE_ID&quot;,C.&quot;GIFT_LIST_REF&quot; \
FROM vdaccount_card_assign C INNER JOIN vd_merchant_master M ON \
C.&quot;MERCHANT_ID&quot;=M.&quot;merchant_id&quot; AND \
C.&quot;MERCHANT_ID&quot;=&#39;003561002966107&#39; INNER JOIN vd_store_master S ON \
S.&quot;store_id&quot;=C.&quot;GIFT_LIST_REF&quot; OR \
C.&quot;GIFT_LIST_REF&quot;=&#39;&#39; INNER JOIN vd_franchisee F ON \
S.&quot;franchisee_id&quot;=F.&quot;franchisee_id&quot; &#39;&#39;&#39;)</span>    \
<br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" \
data-smartmail="gmail_signature"><br>Best Regards, <br>Sachin Kumar<br></div><img \
width="1" height="1" src="http://s.bl-1.com/MczHZCT.gif"></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic