Re: [SQL] Optimize querry sql

2007-09-17 Thread hubert depesz lubaczewski
On Mon, Sep 17, 2007 at 09:17:58AM +0200, Stanislas de Larocque wrote: > Have you advices to optimize the query please ? for some many rows the 400ms looks quite reasonable. the best thing you can make to speed things up is to calculate the counts with triggers. depesz -- quicksil1er: "postgre

Re: [SQL] Optimize querry sql

2007-09-17 Thread Stanislas de Larocque
Hi, I deleted the fonction date_part and now the time of the querry is : 464 ms !!! Limit (cost=1373.32..1373.50 rows=15 width=27) (actual time=463.762..463.857 rows=15 loops=1) -> HashAggregate (cost=1373.32..1408.52 rows=2816 width=27) (actual time=463.755..463.820 rows=15 loops=1)

Re: [SQL] Optimize querry sql

2007-09-15 Thread Michael Glaesemann
On Sep 14, 2007, at 10:17 , Scott Marlowe wrote: OK, I was just afraid there was some "bad thing" TM that I wasn't aware of with now(), which, btw, I use all the time. whew. I use CURRENT_TIMESTAMP and CURRENT_DATE for three reasons: * they're SQL-standard keywords, unlike now(). This might

Re: [SQL] Optimize querry sql

2007-09-14 Thread Scott Marlowe
On 9/14/07, A. Kretschmer <[EMAIL PROTECTED]> wrote: > am Fri, dem 14.09.2007, um 8:36:47 -0500 mailte Scott Marlowe folgendes: > > On 9/14/07, A. Kretschmer <[EMAIL PROTECTED]> wrote: > > > > > And use CURRENT_DATE instead now(). > > > > Out of curiosity, why the advice to switch from now() to C

Re: [SQL] Optimize querry sql

2007-09-14 Thread A. Kretschmer
am Fri, dem 14.09.2007, um 8:36:47 -0500 mailte Scott Marlowe folgendes: > On 9/14/07, A. Kretschmer <[EMAIL PROTECTED]> wrote: > > > And use CURRENT_DATE instead now(). > > Out of curiosity, why the advice to switch from now() to CURRENT_DATE? Mhh, don't know... Andreas -- Andreas Kretsch

Re: [SQL] Optimize querry sql

2007-09-14 Thread hubert depesz lubaczewski
On Fri, Sep 14, 2007 at 03:02:59PM +0200, Stanislas de Larocque wrote: > I want to optimize my query sql (execution time : 2665 ms) : SELECT b.idxreseller, sum(a.nbrq), b.namereseller from stat a, reseller b where b.asp=6 and a.idxreseller=b.reseller and a.month=d

Re: [SQL] Optimize querry sql

2007-09-14 Thread Scott Marlowe
On 9/14/07, A. Kretschmer <[EMAIL PROTECTED]> wrote: > And use CURRENT_DATE instead now(). Out of curiosity, why the advice to switch from now() to CURRENT_DATE? ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your de

[SQL] Optimize querry sql

2007-09-14 Thread Stanislas de Larocque
Hi, I had errors in my last emails. sorry I want to optimize my query sql (execution time : 2665 ms) : SELECT b.idxreseller, sum(a.nbrq), b.namereseller from stat a ,reseller b where b.asp=6 and a.idxreseller=b.reseller and a.month=date_part('month',now() - interval '1 month') and a.year=date_pa

Re: [SQL] Optimize querry sql

2007-09-14 Thread hubert depesz lubaczewski
On Fri, Sep 14, 2007 at 12:26:00PM +0200, Stanislas de Larocque wrote: > Explain my sql querry : did you notice, that andreas asked: > > Show us the output from EXLAIN ANALYSE . depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) htt

Re: [SQL] Optimize querry sql

2007-09-14 Thread A. Kretschmer
am Fri, dem 14.09.2007, um 12:26:00 +0200 mailte Stanislas de Larocque folgendes: > Hi, > > Explain my sql querry : > > Limit (cost=1057.15..1057.16 rows=1 width=27) >-> HashAggregate (cost=1057.15..1057.16 rows=1 width=27) > -> Nested Loop (cost=0.00..1057.14 rows=1 width=27)

Re: [SQL] Optimize querry sql

2007-09-14 Thread Stanislas de Larocque
Hi, Explain my sql querry : Limit (cost=1057.15..1057.16 rows=1 width=27) -> HashAggregate (cost=1057.15..1057.16 rows=1 width=27) -> Nested Loop (cost=0.00..1057.14 rows=1 width=27) -> Seq Scan on stat a (cost=0.00..1042.98 rows=1 width=8) F

Re: [SQL] Optimize querry sql

2007-09-14 Thread A. Kretschmer
am Fri, dem 14.09.2007, um 10:31:39 +0200 mailte Stanislas de Larocque folgendes: > Hi, > > I want to optimize my qerry sql (execution time : 2448 ms) : > > SELECT b.idxreseller, sum(a.nbrq), b.namereseller from stat a > ,reseller b where b.asp=6 and a.idxreseller=b.reseller and > a.month=date_

[SQL] Optimize querry sql

2007-09-14 Thread Stanislas de Larocque
Hi, I want to optimize my qerry sql (execution time : 2448 ms) : SELECT b.idxreseller, sum(a.nbrq), b.namereseller from stat a ,reseller b where b.asp=6 and a.idxreseller=b.reseller and a.month=date_part('month',now() - interval '1 month') and a.year=date_part('year',now() - interval '1 month') G

[SQL] Optimize querry sql

2007-09-14 Thread Stanislas de Larocque
Hi, I want to optimize my qerry sql (execution time : 2448 ms) : SELECT b.idxreseller, sum(a.nbrq), b.namereseller from stat a ,reseller b where b.asp=6 and a.idxreseller=b.reseller and a.month=date_part('month',now() - interval '1 month') and a.year=date_part('year',now() - interval '1 month') G