Re: slow query on tables with new columns added.
От | M. D. |
---|---|
Тема | Re: slow query on tables with new columns added. |
Дата | |
Msg-id | 4E80DCD6.6080401@turnkey.bz обсуждение исходный текст |
Ответ на | Re: slow query on tables with new columns added. (Filip Rembiałkowski <plk.zuber@gmail.com>) |
Ответы |
Re: slow query on tables with new columns added.
|
Список | pgsql-performance |
I have full access to the database, but no access to the application source code. If creating an index will help, I cando 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 helpor create an index. There is an index on the customer_id column in the gltx table, so I'm not sure what else could bedone.<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_idas 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@mail.gmail.com"type="cite"><br /><div class="gmail_quote">2011/9/23M. D. <span dir="ltr"><<a href="mailto:lists@turnkey.bz" moz-do-not-send="true">lists@turnkey.bz</a>></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 whenselecting a customer it queries for the sum of a few columns. This takes 7 seconds for the 'Cash Sale' customer - byfar 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 theonly 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 invoiceleft join gltx on invoice.invoice_id = gltx.gltx_id<br /> where gltx.inactive_on is null and gltx.posted = 'Y' andgltx.customer_id = 'A0ZQ2gsACIsEKLI638ikyg'<br /></blockquote><div><br /> Aside from other things, you know that LEFTjoin here is useless? - planner should collapse it to normal join but I'd check.<br /><br /><br /> Filip<br /><br /></div></div></blockquote><br/>
В списке pgsql-performance по дате отправления: