[SQL] Big table - using wrong index - why?

2001-07-30 Thread Chris Ruprecht
Hi all, I have a table with about 6 million records in it. I have 9 different indexes on the table (different people need to access it differently) If you look at the details below, you can see that it's selecting an index which doesn't have the fields I'm searching with - and it takes for ever.

Re: [SQL] Why does this plpgslq always return 1?

2001-07-30 Thread Jan Wieck
Stephan Szabo wrote: > On Fri, 27 Jul 2001, John Oakes wrote: > > > Can anyone tell me why this always return 1? Thanks! > > > > CREATE FUNCTION passrate(date, date, text) RETURNS float AS ' > > > > DECLARE > > begindate ALIAS FOR $1; > > enddate ALIAS FOR $2; > > passfail ALIAS FOR $3; > > r

Re: [SQL] Big table - using wrong index - why?

2001-07-30 Thread Joe Conway
> phones=# \d i_pl_pseq > Index "i_pl_pseq" > Attribute | Type > ---+-- > entity| character varying(3) > pseq | bigint > btree > > phones=# explain select * from phonelog where entity = '001' and pseq >= > 9120 and pseq <= 9123; > NOTICE: QU

[SQL] plpgsql function return multiple values?

2001-07-30 Thread John Oakes
Is it possible for a plpgsql function to return a record? I need to return multiple values, and preferably in the form of a record. Thanks in advance! John ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister com

Re: [SQL] Date Time Functions - ANSI SQL ?

2001-07-30 Thread Gonzo Rock
At 01:39 AM 7/30/01 -0400, Tom Lane wrote: >Gonzo Rock <[EMAIL PROTECTED]> writes: >> Are all the date time functions described in the pgSQL docs are >> ANSI-SQL or pgSQL extensions? > >One or the other, yes ;-) Hey Tom, You Clever guy! Yes, One or the other! OK OK! Nothing worse than a progra

Re: [SQL] plpgsql function return multiple values?

2001-07-30 Thread Jan Wieck
John Oakes wrote: > Is it possible for a plpgsql function to return a record? I need to return > multiple values, and preferably in the form of a record. Thanks in advance! Not useful in any released version of PostgreSQL. In v7.2 you'll have at least the possibility to return a

Re: [SQL] Big table - using wrong index - why?

2001-07-30 Thread Chris Ruprecht
Hi Joe, I found the problem - it was a typical "rrrhhh" - error. Since pseq is declared int8, I need to say select * from phonelog where entity = '001' and pseq >= 9120::int8 and pseq <= 9123::int8; (casting the two numbers). Then, it works like a charm ... Best regards, Chris -

Re: [SQL] Big table - using wrong index - why?

2001-07-30 Thread Tom Lane
"Chris Ruprecht" <[EMAIL PROTECTED]> writes: > phones=# explain select * from phonelog where entity = '001' and pseq >= > 9120 and pseq <= 9123; > NOTICE: QUERY PLAN: > Index Scan using i_pl_loadtimestamp on phonelog (cost=0.00..209247.39 > rows=607 width=137) Your problem is that pseq is of t