Query Performance Problem

From: <john(at)jpm-cola(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Query Performance Problem
Date: 2014-10-21 12:57:06
Message-ID: 20141021055706.569d35d6ab57613ee80d5d1694a397ee.a433b9a0ea.wbe@email06.secureserver.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;"><div><br></div><div><br></div><div><span>Hi all,</span></div><div><br></div><div>I'm experimenting with table partitioning though inheritance. I'm testing a query as follows:</div><div><br></div><div><div><font face="courier new, monospace">explain (analyze, buffers)</font></div><div><font face="courier new, monospace">select&nbsp;<a href="http://response.id/" target="_blank">response.id</a></font></div><div><font face="courier new, monospace">from claim.response</font></div><div><font face="courier new, monospace">where response.account_id = 4766<br></font></div><div><font face="courier new, monospace">and response.expire_timestamp is null</font></div><div><font face="courier new, monospace">and response.create_timestamp &gt;= DATE '2014-08-01'</font></div><div><font face="courier new, monospace">order by create_timestamp;</font></div></div><div><br></div><div>The response table looks like this:</div><div><div><font face="courier new, monospace">"account_id";"integer"</font></div><div><font face="courier new, monospace">"file_type_id";"integer"</font></div><div><font face="courier new, monospace">"receiver_inbound_detail_id";"<wbr>integer"</font></div><div><font face="courier new, monospace">"processing_status_id";"<wbr>integer"</font></div><div><font face="courier new, monospace">"processing";"boolean"</font></div><div><font face="courier new, monospace">"expire_timestamp";"timestamp without time zone"</font></div><div><font face="courier new, monospace">"last_mod_timestamp";"<wbr>timestamp without time zone"</font></div><div><font face="courier new, monospace">"create_timestamp";"timestamp without time zone"</font></div><div><font face="courier new, monospace">"response_trace_nbr";"<wbr>character varying"</font></div><div><font face="courier new, monospace">"posted_timestamp";"timestamp without time zone"</font></div><div><font face="courier new, monospace">"need_to_post";"boolean"</font></div><div><font face="courier new, monospace">"response_message";"text"</font></div><div><font face="courier new, monospace">"worked";"boolean"</font></div><div><font face="courier new, monospace">"response_status_id";"integer"</font></div><div><font face="courier new, monospace">"response_type_id";"integer"</font></div><div><font face="courier new, monospace">"outbound_claim_detail_id";"<wbr>bigint"</font></div><div><font face="courier new, monospace">"id";"bigint"</font></div></div><div><br></div><div>Here are some rowcounts:</div><div><br></div><div><div><font face="courier new, monospace">SELECT count(*) from claim_response.response_<wbr>201408;</font></div><div><font face="courier new, monospace">&nbsp; count</font></div><div><font face="courier new, monospace">---------</font></div><div><font face="courier new, monospace">&nbsp;4585746</font></div><div><font face="courier new, monospace">(1 row)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Time: 7271.054 ms</font></div><div><font face="courier new, monospace">SELECT count(*) from claim_response.response_<wbr>201409;</font></div><div><font face="courier new, monospace">&nbsp; count</font></div><div><font face="courier new, monospace">---------</font></div><div><font face="courier new, monospace">&nbsp;3523370</font></div><div><font face="courier new, monospace">(1 row)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Time: 4341.116 ms</font></div><div><font face="courier new, monospace">SELECT count(*) from claim_response.response_<wbr>201410;</font></div><div><font face="courier new, monospace">&nbsp;count</font></div><div><font face="courier new, monospace">-------</font></div><div><font face="courier new, monospace">&nbsp; &nbsp;154</font></div><div><font face="courier new, monospace">(1 row)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Time: 0.258 ms</font></div></div><div><br></div><div>The entire table has&nbsp;225,665,512 rows. I read that a partitioning rule of thumb is that benefits of partitioning occur starting around 100 million rows.</div><div><br></div><div><div><font face="courier new, monospace">SELECT count(*) from claim.response;</font></div><div><font face="courier new, monospace">&nbsp; &nbsp;count</font></div><div><font face="courier new, monospace">-----------</font></div><div><font face="courier new, monospace">&nbsp;225665512</font></div><div><font face="courier new, monospace">(1 row)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Time: 685064.637 ms</font></div></div><div><br></div><div><br></div><div>The partitioning is on the create_timestamp field.</div><div><br></div><div>The server is Red Hat Enterprise Linux Server release 6.2 (Santiago) on a VM machine - 8 GB RAM with 2 CPUs:</div><div><br></div><div><div><font face="courier new, monospace">Architecture: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x86_64</font></div><div><font face="courier new, monospace">CPU op-mode(s): &nbsp; &nbsp; &nbsp; &nbsp;32-bit, 64-bit</font></div><div><font face="courier new, monospace">Byte Order: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Little Endian</font></div><div><font face="courier new, monospace">CPU(s): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2</font></div><div><font face="courier new, monospace">On-line CPU(s) list: &nbsp; 0,1</font></div><div><font face="courier new, monospace">Thread(s) per core: &nbsp; &nbsp;1</font></div><div><font face="courier new, monospace">Core(s) per socket: &nbsp; &nbsp;2</font></div><div><font face="courier new, monospace">CPU socket(s): &nbsp; &nbsp; &nbsp; &nbsp; 1</font></div><div><font face="courier new, monospace">NUMA node(s): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1</font></div><div><font face="courier new, monospace">Vendor ID: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GenuineIntel</font></div><div><font face="courier new, monospace">CPU family: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6</font></div><div><font face="courier new, monospace">Model: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 44</font></div><div><font face="courier new, monospace">Stepping: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2</font></div><div><font face="courier new, monospace">CPU MHz: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2660.000</font></div><div><font face="courier new, monospace">BogoMIPS: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5320.00</font></div><div><font face="courier new, monospace">L1d cache: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 32K</font></div><div><font face="courier new, monospace">L1i cache: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 32K</font></div><div><font face="courier new, monospace">L2 cache: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;256K</font></div><div><font face="courier new, monospace">L3 cache: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;12288K</font></div><div><font face="courier new, monospace">NUMA node0 CPU(s): &nbsp; &nbsp; 0,1</font></div></div><div><br></div><div><br></div><div><br></div><div>2 users, &nbsp;load average: 0.00, 0.12, 0.37</div><div><br></div><div><br></div><div>Please see the following for the explain analysis :</div><div><br></div><div><a href="http://explain.depesz.com/s/I3SL" target="_blank">http://explain.depesz.com/s/<wbr>I3SL</a><br></div><div><br></div><div>I'm trying to understand why I'm getting the yellow, orange, and red on the inclusive, and the yellow on the exclusive. (referring to the&nbsp;<a href="http://explain.depesz.com/s/I3SL" target="_blank">explain.depesz.com/s/I3SL</a>&nbsp;page.)</div><div>I'm relatively new to PostgreSQL, but I've been an Oracle DBA for some time. I suspect the I/O may be dragging but I don't know how to dig that information out from here. Please point out anything else you can decipher from this.&nbsp;</div><div><br></div><div>Thanks,</div><div><br></div><div style="">John</div></span></body></html>

Attachment Content-Type Size
unknown_filename text/html 7.9 KB

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Felipe Santos 2014-10-21 13:16:49 Re: Query Performance Problem
Previous Message Felipe Santos 2014-10-21 10:45:01 Re: Query with large number of joins