Re: [PERFORM] adding 'limit' leads to very slow query

2005-03-07 Thread Stephan Szabo
On Mon, 7 Mar 2005, Michael McFarland wrote: >I'm trying to understand why a particular query is slow, and it seems > like the optimizer is choosing a strange plan. See this summary: > > > * I have a large table, with an index on the primary key 'id' and on a > field 'foo'. > > select count(*

Re: [PERFORM] adding 'limit' leads to very slow query

2005-03-07 Thread John A Meinel
Michael McFarland wrote: I'm trying to understand why a particular query is slow, and it seems like the optimizer is choosing a strange plan. See this summary: ... explain select * from foo where barId = 412 order by id desc limit 25; Limit () -> Index scan backward using primarykey_index

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread John A Meinel
Tom Lane wrote: John A Meinel <[EMAIL PROTECTED]> writes: Dave Held wrote: There is always clock(). My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and it had a resolution of 55clocks / s. When I just did this: The other problem is it measures process CP

[PERFORM] performance problems

2005-03-07 Thread Michael Zoephel
Hi,   I have performance problems with the postmaster-process. The CPU usage is permanently  around 90 %.   My DB:       3,5 GB Size     largest table ca. 700 000 rows   Most access:       Finde a row - Update if exist Insert else   Average access:       10 times a second       every Query ne

[PERFORM] Help with slow running query

2005-03-07 Thread jesse d
The following query takes approx. 3-5+ minutes to complete. I would like to get this down to around 2-3 seconds. Other RDBMS complete it in <1 second. I am running 8.0.1 on XP P4 2.6 1GB for dev work. select i.internalid, c.code from local.internal i inner join country.ip c on (i.ip between c.st

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Dave Page
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Tom Lane > Sent: 07 March 2005 22:57 > To: John A Meinel > Cc: Dave Held; pgsql-performance@postgresql.org; > [EMAIL PROTECTED] > Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning >

[PERFORM] adding 'limit' leads to very slow query

2005-03-07 Thread Michael McFarland
I'm trying to understand why a particular query is slow, and it seems like the optimizer is choosing a strange plan. See this summary: * I have a large table, with an index on the primary key 'id' and on a field 'foo'. select count(*) from foo; 1,000,000 select count(*) from foo where bar =

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread PFC
From the Linux Kernel (make menuconfig) there seem to be two new reliable sources for timing information. Note the remark about "Time Stamp Counter" below. Question is, which one of these (or others) are your API functions using ? I have absolutely no idea ! CONFIG_HPET_TIMER:

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Steinar H. Gunderson
On Mon, Mar 07, 2005 at 09:02:38PM -0500, Tom Lane wrote: > One thought that was bothering me was that if the CPU goes idle while > waiting for disk I/O, its clock might stop or slow down dramatically. > If we believed such a counter for EXPLAIN, we'd severely understate > the cost of disk I/O. >

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Tom Lane
"Steinar H. Gunderson" <[EMAIL PROTECTED]> writes: > RDTSC is a bad source of information for this kind of thing, as the CPU > frequency might vary. One thought that was bothering me was that if the CPU goes idle while waiting for disk I/O, its clock might stop or slow down dramatically. If we bel

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Steinar H. Gunderson
On Mon, Mar 07, 2005 at 06:11:34PM -0600, Dave Held wrote: >> In which case using it would be a mistake. Since rtdsc doesn't >> work across processors. > It doesn't always use RDTSC. I can't find anything authoritative on > when it does. I would assume that it would use RDTSC when available > and

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Dave Held
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED] > Sent: Monday, March 07, 2005 4:57 PM > To: John A Meinel > Cc: Dave Held; pgsql-performance@postgresql.org; > [EMAIL PROTECTED] > Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning > this query > (with > > John A

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Dave Held
> -Original Message- > From: Greg Stark [mailto:[EMAIL PROTECTED] > Sent: Monday, March 07, 2005 5:15 PM > To: Dave Held > Cc: Greg Stark; John A Meinel; Tom Lane; Magnus Hagander; Ken > Egervari; > pgsql-performance@postgresql.org; [EMAIL PROTECTED] > Subject: Re: [pgsql-hackers-win32] [P

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Greg Stark
"Dave Held" <[EMAIL PROTECTED]> writes: > > What would be really neato would be to use the rtdsc (sp?) or > > equivalent assembly instruction where available. Most processors > > provide such a thing and it would give much lower overhead and much > > more accurate answers. > > > > The main prob

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Tom Lane
John A Meinel <[EMAIL PROTECTED]> writes: > Dave Held wrote: >> There is always clock(). > My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and > it had a resolution of 55clocks / s. When I just did this: The other problem is it measures process CPU time, not elapsed time whi

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread John A Meinel
Dave Held wrote: There is always clock(). It's mandated by ANSI C, but my docs say that POSIX requires CLOCKS_PER_SEC == 100 regardless of actual timer resolution, which seems a little brain-dead to me. __ David B. Held My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, an

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with explain analyze finally)

2005-03-07 Thread Dave Held
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED] > Sent: Monday, March 07, 2005 10:39 AM > To: John A Meinel > Cc: Magnus Hagander; Ken Egervari; pgsql-performance@postgresql.org; > [EMAIL PROTECTED] > Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning > this quer

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Dave Held
> -Original Message- > From: Greg Stark [mailto:[EMAIL PROTECTED] > Sent: Monday, March 07, 2005 12:06 PM > To: John A Meinel > Cc: Tom Lane; Magnus Hagander; Ken Egervari; > pgsql-performance@postgresql.org; [EMAIL PROTECTED] > Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning

Re: [PERFORM] Help trying to tune query that executes 40x slower than in SqlServer

2005-03-07 Thread Tom Lane
Hugo Ferreira <[EMAIL PROTECTED]> writes: > SELECT 514, 1168, C.contxt_id, C.contxt_elmt_ix, null, null, > null, null, null, null, 1 > FROM CONTXT as P INNER JOIN CONTXT_ELMT as C on P.contxt_id = C.contxt_id >INNER JOIN MRS_REPLICATION_OUT as S on S.ent_id=1029 >

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread Greg Stark
John A Meinel <[EMAIL PROTECTED]> writes: > Then we would only be wrong for 256 gettimeofday calls. I agree it isn't > great, though. And probably better to just abstract (possibly just with > #ifdef) the calls for accurate timing, from the calls that actually need > the real time. What would be

Re: [PERFORM] Help trying to tune query that executes 40x slower than in SqlServer

2005-03-07 Thread Hugo Ferreira
I'm sorry for my unpolite query alignment. Here is the query in a more human-readable format: SELECT 514, 1168, C.contxt_id, C.contxt_elmt_ix, null, null, null, null, null, null, 1 FROM CONTXT as P INNER JOIN CONTXT_ELMT as C on P.contxt_id = C.contxt_id INNER JOIN MRS_REPLICATION_OUT

Re: [PERFORM] Tuning, configuration for 7.3.5 on a Sun E4500

2005-03-07 Thread Josh Berkus
Tsarevich, > When running queries we are experiencing much bigger result times than > anticipated. > > Attached is a copy of our postgresql.conf file and of our the table > definitions and row counts. Looks like you haven't run ANALYZE on the database anytime recently. Try that and re-run. --

Re: [PERFORM] Help trying to tune query that executes 40x slower than in SqlServer

2005-03-07 Thread Josh Berkus
Hugo, > insert into MRS_REPLICATION_OUT select 514, 1168,  C.contxt_id, > C.contxt_elmt_ix, CAST(null as NUMERIC(18)), CAST(null as > NUMERIC(18)), CAST(null as NUMERIC(18)), CAST(null as NUMERIC(18)), > CAST(null as NUMERIC(18)), null, 1 from c2iedm.CONTXT as P inner join > c2iedm.CONTXT_ELMT

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread John A Meinel
Tom Lane wrote: John A Meinel <[EMAIL PROTECTED]> writes: Can we just replace gettimeofday() with a version that's basically: No, because it's also used for actual time-of-day calls. It'd be necessary to hack executor/instrument.c in particular. Or we modify the win32 gettimeofday call to som

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with explain analyze finally)

2005-03-07 Thread Tom Lane
John A Meinel <[EMAIL PROTECTED]> writes: >>> Can we just replace gettimeofday() with a version that's basically: >> >> No, because it's also used for actual time-of-day calls. It'd be >> necessary to hack executor/instrument.c in particular. > Or we modify the win32 gettimeofday call to somethi

[PERFORM] Help trying to tune query that executes 40x slower than in SqlServer

2005-03-07 Thread Hugo Ferreira
Hi there :-) I'm really, really having trouble with this query... It is a part of, hmmm... 200 similar querys that I dinyamically build and run in a stored procedure. This one, for example, takes 27seconds to run. The whole stored procedure executes in about 15minutes. This is too much when compar

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with

2005-03-07 Thread John A Meinel
Tom Lane wrote: "Magnus Hagander" <[EMAIL PROTECTED]> writes: There is. I beleive QueryPerformanceCounter has sub-mirosecond resolution. Can we just replace gettimeofday() with a version that's basically: No, because it's also used for actual time-of-day calls. It'd be necessary to hack executor

[PERFORM] Tuning, configuration for 7.3.5 on a Sun E4500

2005-03-07 Thread tsarevich
Env: Sun E4500 with 8 gig of RAM in total. Database is stored locally (not on a network storage devise). A copy of the postgresql.conf file is attached. When running queries we are experiencing much bigger result times than anticipated. Attached is a copy of our postgresql.conf file and of our

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with explain analyze finally)

2005-03-07 Thread Tom Lane
"Magnus Hagander" <[EMAIL PROTECTED]> writes: > There is. I beleive QueryPerformanceCounter has sub-mirosecond > resolution. > Can we just replace gettimeofday() with a version that's basically: No, because it's also used for actual time-of-day calls. It'd be necessary to hack executor/instrumen

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with explain analyze finally)

2005-03-07 Thread Magnus Hagander
> > Do we need actual high precision time, or do we just need > to be able > > to get high precision differences? Getting the differences > is fairly > > easy, but if you need to "sync up" any drif then it becomes > a bit more > > difficult. > > You're right, we only care about differences n

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with explain analyze finally)

2005-03-07 Thread Tom Lane
"Magnus Hagander" <[EMAIL PROTECTED]> writes: > Do we need actual high precision time, or do we just need to be able to > get high precision differences? Getting the differences is fairly easy, > but if you need to "sync up" any drif then it becomes a bit more > difficult. You're right, we only ca

Re: [pgsql-hackers-win32] [PERFORM] Help with tuning this query (with explain analyze finally)

2005-03-07 Thread Magnus Hagander
> >> What platform is this on? It seems very strange/fishy > that all the > >> actual-time values are exact integral milliseconds. > > > My machine is WinXP professional, athon xp 2100, but I get similar > > results on my Intel P4 3.0Ghz as well (which is also > running WinXP). > > Why do y