Re: slow query on tables with new columns added.

From: "M(dot) D(dot)" <lists(at)turnkey(dot)bz>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: slow query on tables with new columns added.
Date: 2011-09-26 20:13:10
Message-ID: 4E80DCD6.6080401@turnkey.bz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I have full access to the database, but no access to the application
source code.  If creating an index will help, I can do that, but
with the columns I don't see it helping as I don't have access to
the application source to change that. <br>
<br>
So yes, by changing settings, I would like to know if there's any
memory settings I can change to help or create an index.  There is
an index on the customer_id column in the gltx table, so I'm not
sure what else could be done.<br>
<br>
If there was a way to create a select trigger, I would do it and
return 0 for both columns on that customer_id as it should always be
0.<br>
<br>
<br>
On 09/24/2011 12:10 AM, Filip Rembiałkowski wrote:
<blockquote
cite="mid:CAP_rww=w1fHxy01-hMciengN=6ovxtZWN4FgRDNdywb-Htm3iQ(at)mail(dot)gmail(dot)com"
type="cite"><br>
<div class="gmail_quote">2011/9/23 M. D. <span dir="ltr">&lt;<a
moz-do-not-send="true" href="mailto:lists(at)turnkey(dot)bz">lists(at)turnkey(dot)bz</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I did a software upgrade, and with it came a new feature where
when selecting a customer it queries for the sum of a few
columns.  This takes 7 seconds for the 'Cash Sale' customer -
by far the most active customer. I'd like to see if it's
possible to get it down a bit by changing settings.<br>
<br>
</blockquote>
<div><br>
To make things clear before we search for a solution. You
wrote "by changing settings". Is it the only option? Can't you
change the query in software? Can't you change database schema
(add indexes etc)?<br>
 
<br>
<br>
</div>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
Query:<br>
explain analyse select sum(item_points),sum(disc_points) from
invoice left join gltx on invoice.invoice_id = gltx.gltx_id<br>
where gltx.inactive_on is null and gltx.posted = 'Y' and
gltx.customer_id = 'A0ZQ2gsACIsEKLI638ikyg'<br>
</blockquote>
<div><br>
Aside from other things, you know that LEFT join here is
useless? - planner should collapse it to normal join but I'd
check.<br>
<br>
<br>
Filip<br>
<br>
</div>
</div>
</blockquote>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.8 KB

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Timothy Garnett 2011-09-26 21:11:33 Re: Performance Anomaly with "col in (A,B)" vs. "col = A OR col = B" ver. 9.0.3
Previous Message Marti Raudsepp 2011-09-26 19:06:51 Re: [PERFORMANCE] Insights: fseek OR read_cluster?