Re: [PERFORM] Index usage for tstzrange?

2013-03-22 Thread Tom Lane
Heikki Linnakangas hlinnakan...@vmware.com writes: We should do this automatically. Or am I missing something? Yes. This is not equality. ALTER OPERATOR FAMILY integer_ops USING btree ADD OPERATOR 3 @ (int4, int4range), FUNCTION 1 btint4rangecmp(int4, int4range); That will break

Re: [PERFORM] Index usage for tstzrange?

2013-03-21 Thread Heikki Linnakangas
On 21.03.2013 06:07, Vasilis Ventirozos wrote: On Thu, Mar 21, 2013 at 5:58 AM, Tom Lanet...@sss.pgh.pa.us wrote: What I find more disturbing is that this is what I get from the example in HEAD: regression=# explain SELECT * FROM a WHERE ts@ tstzrange('2013-01-01','2013-01-01 00:10:00');

Re: [PERFORM] Index usage for tstzrange?

2013-03-21 Thread Josh Berkus
Well, no. @ is not a btree-indexable operator. Yes, but it's equivalent to ( ( a = b1 or b1 is null ) and ( a b2 or b2 is null ) ), which *is* btree-indexable and can use an index. So it seems like the kind of optimization we could eventually make. -- Josh Berkus PostgreSQL Experts Inc.

[PERFORM] Index usage for tstzrange?

2013-03-20 Thread Josh Berkus
Folks, I just noticed that if I use a tstzrange for convenience, a standard btree index on a timestamp won't get used for it. Example: table a ( id int, val text, ts timestamptz ); index a_ts on a(ts); SELECT * FROM a WHERE ts @ tstzrange('2013-01-01','2013-01-01

Re: [PERFORM] Index usage for tstzrange?

2013-03-20 Thread Tom Lane
Josh Berkus j...@agliodbs.com writes: I just noticed that if I use a tstzrange for convenience, a standard btree index on a timestamp won't get used for it. Example: table a ( id int, val text, ts timestamptz ); index a_ts on a(ts); SELECT * FROM a WHERE ts @

Re: [PERFORM] index usage for min() vs. order by asc limit 1

2011-11-18 Thread MirrorX
can you run an analyze command first and then post here the results of: select * FROM pg_stats WHERE tablename = 'delayed_jobs'; ? -- View this message in context: http://postgresql.1045698.n5.nabble.com/index-usage-for-min-vs-order-by-asc-limit-1-tp5002928p5004410.html Sent from the PostgreSQL

[PERFORM] index usage for min() vs. order by asc limit 1

2011-11-17 Thread Ben Chobot
I have two queries in PG 9.1. One uses an index like I would like, the other does not. Is this expected behavior? If so, is there any way around it? postgres=# explain analyze select min(id) from delayed_jobs where strand='sis_batch:account:15' group by strand;

Re: [PERFORM] index usage for min() vs. order by asc limit 1

2011-11-17 Thread Steve Atkins
On Nov 17, 2011, at 5:12 PM, Ben Chobot wrote: I have two queries in PG 9.1. One uses an index like I would like, the other does not. Is this expected behavior? If so, is there any way around it? I don't think you want the group by in that first query. Cheers, Steve postgres=#

Re: [PERFORM] index usage for min() vs. order by asc limit 1

2011-11-17 Thread Ben Chobot
On Nov 17, 2011, at 5:20 PM, Steve Atkins wrote: I don't think you want the group by in that first query. Heh, I tried to simply the example, but in reality that = becomes an in clause of multiple values. So the group by is needed. postgres=# explain analyze select min(id) from

Re: [PERFORM] index usage on queries on inherited tables

2011-04-29 Thread Robert Haas
On Apr 27, 2011, at 11:11 PM, Joseph Shraibman j...@selectacast.net wrote: On 04/27/2011 04:32 PM, Robert Haas wrote: In the first case, PostgreSQL evidently thinks that using the indexes will be slower than just ignoring them. You could find out whether it's right by trying it with

Re: [PERFORM] index usage on queries on inherited tables

2011-04-27 Thread Robert Haas
On Fri, Apr 1, 2011 at 2:41 AM, Joseph Shraibman j...@selectacast.net wrote: When I do a query on a table with child tables on certain queries pg uses indexes and on others it doesn't. Why does this happen? For example: [local]:playpen= explain analyze select * from vis where id 10747 ;    

Re: [PERFORM] index usage on queries on inherited tables

2011-04-27 Thread Joseph Shraibman
On 04/27/2011 04:32 PM, Robert Haas wrote: In the first case, PostgreSQL evidently thinks that using the indexes will be slower than just ignoring them. You could find out whether it's right by trying it with enable_seqscan=off. My point is that this is just a problem with inherited tables.

Re: [PERFORM] index usage on queries on inherited tables

2011-04-27 Thread Samuel Gendler
On Wed, Apr 27, 2011 at 2:11 PM, Joseph Shraibman j...@selectacast.netwrote: On 04/27/2011 04:32 PM, Robert Haas wrote: In the first case, PostgreSQL evidently thinks that using the indexes will be slower than just ignoring them. You could find out whether it's right by trying it with

Re: [PERFORM] index usage on queries on inherited tables

2011-04-27 Thread Greg Smith
Joseph Shraibman wrote: In a 52 gig table I have a select id from table limit 1 order by id desc returns instantly, but as soon as you declare a child table it tries to seq scan all the tables. This is probably the limitation that's fixed in PostgreSQL 9.1 by this commit (following a few

[PERFORM] Index usage with functions in where condition

2010-07-09 Thread Jeremy Palmer
I'm having trouble getting the query planner to use indexes. The situation occurs when writing a query that uses functions for defining the parameters for the conditions on the indexed columns. The system I'm running is Windows Server 2003, using version 8.4.2 of PostgreSQL. This is the

Re: [PERFORM] Index usage with functions in where condition

2010-07-09 Thread Tom Lane
Jeremy Palmer jpal...@linz.govt.nz writes: This is the query that does not use the indexes: SELECT coo.nod_id, 640*radians(sqrt((coo.value1 - -41.0618)^2+((coo.value2 - 175.58461)*cos(radians(-41.0618)))^2)) as distance FROM crs_coordinate coo WHERE coo.value1 between

Re: [PERFORM] Index usage with functions in where condition

2010-07-09 Thread Jeremy Palmer
Palmer Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Index usage with functions in where condition Jeremy Palmer jpal...@linz.govt.nz writes: This is the query that does not use the indexes: SELECT coo.nod_id, 640*radians(sqrt((coo.value1 - -41.0618)^2+((coo.value2

[PERFORM] index usage in not like

2010-02-18 Thread AI Rumman
Not like operation does not use index. select * from vtiger_contactscf where lower(cf_1253) not like lower('Former%') I created index on lower(cf_1253). How can I ensure index usage in not like operation? Anyone please help.

Re: [PERFORM] index usage in not like

2010-02-18 Thread Thom Brown
On 18 February 2010 11:55, AI Rumman rumman...@gmail.com wrote: Not like operation does not use index. select * from vtiger_contactscf where lower(cf_1253) not like lower('Former%') I created index on lower(cf_1253). How can I ensure index usage in not like operation? Anyone please help.

Re: [PERFORM] index usage in not like

2010-02-18 Thread Thom Brown
On Thu, Feb 18, 2010 at 6:00 PM, Thom Brown thombr...@gmail.com wrote: On 18 February 2010 11:55, AI Rumman rumman...@gmail.com wrote: Not like operation does not use index. select * from vtiger_contactscf where lower(cf_1253) not like lower('Former%') I created index on

Re: [PERFORM] index usage in not like

2010-02-18 Thread A. Kretschmer
In response to Thom Brown : On 18 February 2010 11:55, AI Rumman rumman...@gmail.com wrote: Not like operation does not use index. select * from vtiger_contactscf where lower(cf_1253) not like lower('Former%') I created index on lower(cf_1253). How can I ensure index usage in not

Re: [PERFORM] index usage in not like

2010-02-18 Thread Kenneth Marshall
On Thu, Feb 18, 2010 at 01:18:10PM +0100, A. Kretschmer wrote: In response to Thom Brown : On 18 February 2010 11:55, AI Rumman rumman...@gmail.com wrote: Not like operation does not use index. select * from vtiger_contactscf where lower(cf_1253) not like lower('Former%') I

Re: [PERFORM] index usage in not like

2010-02-18 Thread Thom Brown
On 18 February 2010 12:18, A. Kretschmer andreas.kretsch...@schollglas.com wrote: In response to Thom Brown : On 18 February 2010 11:55, AI Rumman rumman...@gmail.com wrote: Not like operation does not use index. select * from vtiger_contactscf where lower(cf_1253) not like

Re: [PERFORM] index usage in not like

2010-02-18 Thread A. Kretschmer
In response to Kenneth Marshall : How many rows do you have in your table? If there are relatively few, it probably guesses it to be cheaper to do a sequential scan and calculate lower values on-the-fly rather than bother with the index. That's one reason, an other reason, i think,

[PERFORM] Index usage with sub select or inner joins

2008-11-12 Thread Julien Theulier
Hello, I am doing some performances testing on Postgres I discovered the following behavior, when using 2 different ways of writing selects (but doing the same aggregations at the end): 1. test case 1, using outer join: create table test2 as select soj_session_log_id, pv_timestamp,

Re: [PERFORM] Index usage with sub select or outer joins

2008-11-12 Thread Julien Theulier
Cc : pgsql-performance@postgresql.org Objet : Re: [PERFORM] Index usage with sub select or inner joins On Wed, Nov 12, 2008 at 02:22:47PM +0100, Julien Theulier wrote: QUESTION: Why the planner choose seq scan in the first case indexes scan in the second case? In a more general way, I observed

Re: [PERFORM] Index usage with sub select or inner joins

2008-11-12 Thread Joshua Tolley
On Wed, Nov 12, 2008 at 02:22:47PM +0100, Julien Theulier wrote: QUESTION: Why the planner choose seq scan in the first case indexes scan in the second case? In a more general way, I observed that the planner has difficulties to select index scans does in almost all the cases seq scan, when

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-31 Thread Gregory Stark
Tom Lane [EMAIL PROTECTED] writes: Jeff Frost [EMAIL PROTECTED] writes: Tom Lane wrote: Huh. That does sound like it's a version-to-version difference. There's nothing in the CVS log that seems related though. Are you willing to post your test case? It's a customer DB, so I'll contact

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-31 Thread Jeff Frost
On Fri, 31 Oct 2008, Gregory Stark wrote: Tom Lane [EMAIL PROTECTED] writes: Jeff Frost [EMAIL PROTECTED] writes: Tom Lane wrote: Huh. That does sound like it's a version-to-version difference. There's nothing in the CVS log that seems related though. Are you willing to post your test

[PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Jeff Frost
I've run across a strange problem with PG 8.3.3 not using indexes on a particular table after building the table during a transaction. You can see a transcript of the issue here: http://gist.github.com/21154 Interestingly, if I create another temp table 'CREATE TEMP TABLE AS SELECT * FROM act'

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Tom Lane
Jeff Frost [EMAIL PROTECTED] writes: I've run across a strange problem with PG 8.3.3 not using indexes on a particular table after building the table during a transaction. This may be a HOT side-effect ... is pg_index.indcheckxmin set for the index? regards, tom lane

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Tom Lane
Jeff Frost [EMAIL PROTECTED] writes: Tom Lane wrote: This may be a HOT side-effect ... is pg_index.indcheckxmin set for the index? Yep, sure enough, the 'act' table's indexes have it set and jefftest and jefftest2's indexes do not. Okay. What that means is that the indexes were created on

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Jeff Frost
Tom Lane wrote: Okay. What that means is that the indexes were created on data that had already been inserted and updated to some extent, resulting in HOT-update chains that turned out to be illegal for the new indexes. The way we deal with this is to mark the indexes as not usable by any

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Tom Lane
Jeff Frost [EMAIL PROTECTED] writes: Tom Lane wrote: Okay. What that means is that the indexes were created on data that had already been inserted and updated to some extent, resulting in HOT-update chains that turned out to be illegal for the new indexes. The way we deal with this is to

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Jeff Frost
On Thu, 30 Oct 2008, Tom Lane wrote: Any idea why I don't see it on 8.3.4? I think it's more likely some small difference in your test conditions than any real version-to-version difference. In particular I think the still see test might be influenced by the ages of transactions running

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Tom Lane
Jeff Frost [EMAIL PROTECTED] writes: On Thu, 30 Oct 2008, Tom Lane wrote: Any idea why I don't see it on 8.3.4? I think it's more likely some small difference in your test conditions than any real version-to-version difference. In particular I think the still see test might be influenced

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Jeff Frost
Tom Lane wrote: Jeff Frost [EMAIL PROTECTED] writes: On Thu, 30 Oct 2008, Tom Lane wrote: Any idea why I don't see it on 8.3.4? I think it's more likely some small difference in your test conditions than any real version-to-version difference. In particular I think the

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Tom Lane
Jeff Frost [EMAIL PROTECTED] writes: Tom Lane wrote: Huh. That does sound like it's a version-to-version difference. There's nothing in the CVS log that seems related though. Are you willing to post your test case? It's a customer DB, so I'll contact them and see if we can boil it down

[PERFORM] index usage on arrays

2008-02-07 Thread andrew klassen
I am using Postgres 8.2.5. I have a table that has rows containing a variable length array with a known maximum. I was doing selects on the array elements using an ANY match. The performance was not too good as my table got bigger. So I added an index on the array. That didn't help since

Re: [PERFORM] index usage on arrays

2008-02-07 Thread Tom Lane
andrew klassen [EMAIL PROTECTED] writes: Is there any alternative to what am I currently doing other than creating a row for each array element, Since (I think) 8.2, you could create a GIN index on the array column and then array overlap () would be indexable. GIN has some performance

Re: [PERFORM] index usage on arrays

2008-02-07 Thread Oleg Bartunov
andrew, what are your queries ? Have you seen contrib/intarray, GIN index ? On Thu, 7 Feb 2008, andrew klassen wrote: I am using Postgres 8.2.5. I have a table that has rows containing a variable length array with a known maximum. I was doing selects on the array elements using an ANY

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-18 Thread valgog
Hi Tom, do you think it would be a good idea to ask GIN index team to implement an int-based bitmap set indexing operator for GIN/GiST based indexes? Or there will be a possibility to somehow optimally index arrays of enumerations to implement such bitmap structures in 8.3 or later postgresql

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-17 Thread valgog
Hi, I could not find and normal solution for that issue. But I am using some workarounds for that issue. The solution, that I am using now is to create an index for every bit of your bitmap field. So something like CREATE INDEX idx_hobbybit_0_limited ON versionA.user_fast_index USING btree

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-17 Thread valgog
What about saying?: TBL1.CATEGORY = TBL2.CATEGORY Are you sure you understood what was the question? Is the TBL1.CATEGORY = TBL2.CATEGORY the same as TBL1.CATEGORY TBL2.CATEGORY 0? ---(end of broadcast)--- TIP 6: explain analyze is your

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-17 Thread Kevin Grittner
On Mon, Sep 17, 2007 at 2:49 AM, in message [EMAIL PROTECTED], valgog [EMAIL PROTECTED] wrote: What about saying?: TBL1.CATEGORY = TBL2.CATEGORY Are you sure you understood what was the question? Is the TBL1.CATEGORY = TBL2.CATEGORY the same as TBL1.CATEGORY TBL2.CATEGORY 0?

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-17 Thread Tom Lane
Kevin Grittner [EMAIL PROTECTED] writes: On Mon, Sep 17, 2007 at 2:49 AM, in message [EMAIL PROTECTED], valgog [EMAIL PROTECTED] wrote:=20 Are you sure you understood what was the question? Is the TBL1.CATEGORY = TBL2.CATEGORY the same as TBL1.CATEGORY TBL2.CATEGORY 0? Yes, given that

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-17 Thread Kevin Grittner
On Mon, Sep 17, 2007 at 8:37 AM, in message [EMAIL PROTECTED], Tom Lane [EMAIL PROTECTED] wrote: Kevin Grittner [EMAIL PROTECTED] writes: On Mon, Sep 17, 2007 at 2:49 AM, in message [EMAIL PROTECTED], valgog [EMAIL PROTECTED] wrote:=20 Are you sure you understood what was the question?

Re: [PERFORM] Index usage when bitwise operator is used

2007-09-17 Thread W.Alphonse HAROUNY
Hi, A little clarification. Actually, TBL1.CATEGORY and/or TBL2.CATEGORY may hold a binary value having multiple binary(ies) '1'. Each binary value column represent an business attribute. If a binary value column is equal to '1', it means that the business attribute is True, otherwise it is

[PERFORM] Index usage when bitwise operator is used

2007-09-13 Thread W.Alphonse HAROUNY
Hello, My question is about index usage when bitwise operations are invoked. Situation Context: -- Lets suppose we have 2 tables TBL1 and TBL2 as the following: TBL1 { . ; integer categoryGroup; // categoryGroup is declared as an index on TABL1 . ; }

[PERFORM] index usage

2007-04-23 Thread Arkadiusz Raj
Hi, I have a table in my database that is updated every minute with new acquired data. Anyway there is a query to get latest values to be displayed on screen. I have postgresql 7.4.2 that work very fine. The problem was that after hdd crash I have rebuild database from the archive and...

Re: [PERFORM] index usage

2007-04-23 Thread Steinar H. Gunderson
On Mon, Apr 23, 2007 at 07:20:29PM +0200, Arkadiusz Raj wrote: I have a table in my database that is updated every minute with new acquired data. Anyway there is a query to get latest values to be displayed on screen. I have postgresql 7.4.2 that work very fine. You want _at least_ the

[PERFORM] Index usage

2006-08-21 Thread Scott Matseas
We're having a problem with one of our queries being slow. It appears to be due to the index being used to go from tableA to tableB. Here are the tables: CREATE TABLE tableA ( table_idA int8 NOT NULL DEFAULT nextval('tableA_id_seq'::regclass), CONSTRAINT table_idA_pk PRIMARY KEY (table_idA), )

Re: [PERFORM] Index usage

2006-08-21 Thread Tom Lane
Scott Matseas [EMAIL PROTECTED] writes: If I enable sequential scan the Index Cond in question gets replaced with a Seq scan. What other planner parameters have you been fooling with? With no data in the tables, I get a reasonably sane-looking plan, so I'm thinking you've chosen bad values for

Re: [PERFORM] Index usage

2006-08-21 Thread Scott Matseas
Tom Lane wrote: What other planner parameters have you been fooling with? Hi Tom, The other parameters that have been changed are: set join_collapse_limit to 1 set enable_sort to off We are using version 8.1.3. We've noticed the query plan changing depending on the amount of data in the tables

[PERFORM] index usage

2006-07-28 Thread Ben
I have a table with 37000 rows, an integer column, and an index on that column. I've got a function that returns an integer. When I do a select where I restrict that column to being equal to a static number, explain tells me the index will be used. When I do the same thing but use the function

Re: [PERFORM] index usage

2006-07-28 Thread Daniel Caune
De : [EMAIL PROTECTED] [mailto:pgsql-performance- [EMAIL PROTECTED] De la part de Ben Envoyé : vendredi, juillet 28, 2006 15:21 À : pgsql-performance@postgresql.org Objet : [PERFORM] index usage I have a table with 37000 rows, an integer column, and an index on that column. I've got

Re: [PERFORM] index usage

2006-07-28 Thread Ben
It's volatile, but it will always return an integer. On Fri, 28 Jul 2006, Daniel Caune wrote: De : [EMAIL PROTECTED] [mailto:pgsql-performance- [EMAIL PROTECTED] De la part de Ben Envoyé : vendredi, juillet 28, 2006 15:21 À : pgsql-performance@postgresql.org Objet : [PERFORM] index usage I

Re: [PERFORM] index usage

2006-07-28 Thread Mark Lewis
return an integer. On Fri, 28 Jul 2006, Daniel Caune wrote: De : [EMAIL PROTECTED] [mailto:pgsql-performance- [EMAIL PROTECTED] De la part de Ben Envoyé : vendredi, juillet 28, 2006 15:21 À : pgsql-performance@postgresql.org Objet : [PERFORM] index usage I have a table with 37000

Re: [PERFORM] index usage

2006-07-28 Thread Tom Lane
Ben [EMAIL PROTECTED] writes: It's volatile, but it will always return an integer. If it's volatile then it can't be used for an index condition. regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the

Re: [PERFORM] Index Usage using IN

2006-02-01 Thread Jeffrey W. Baker
On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote: Hi, I have 2 tables both have an index on ID (both ID columns are an oid). I want to find only only rows in one and not the other. Select ID from TableA where ID not IN ( Select ID from Table B) Have you considered this: SELECT ID

Re: [PERFORM] Index Usage using IN

2006-02-01 Thread Jeffrey W. Baker
On Wed, 2006-02-01 at 12:22 -0800, Jeffrey W. Baker wrote: On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote: Hi, I have 2 tables both have an index on ID (both ID columns are an oid). I want to find only only rows in one and not the other. Select ID from TableA where ID not

Re: [PERFORM] Index Usage using IN

2006-02-01 Thread Tom Lane
Jeffrey W. Baker [EMAIL PROTECTED] writes: On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote: Select ID from TableA where ID not IN ( Select ID from Table B) Have you considered this: SELECT ID from TableA EXCEPT Select ID from Table B Also, increasing work_mem might persuade the planner

Re: [PERFORM] Index Usage using IN

2006-02-01 Thread Bruno Wolff III
On Thu, Feb 02, 2006 at 09:12:59 +1300, Ralph Mason [EMAIL PROTECTED] wrote: Hi, I have 2 tables both have an index on ID (both ID columns are an oid). I want to find only only rows in one and not the other. Select ID from TableA where ID not IN ( Select ID from Table B) This always

Re: [PERFORM] Index Usage using IN

2006-02-01 Thread Hari Warrier
Select ID from TableA where not exists ( Select ID from Table B where ID = TableA.ID) might give you index scan. Of course, that is only useful is TableA is very small table. Not appropriate for 250k rows on 2/1/2006 12:12 PM Ralph Mason said the following: Hi, I have 2 tables both have an

Re: [PERFORM] Index usage for sorted query

2004-11-22 Thread Markus Schaber
Hi, Pierre-Frédéric, On Sat, 20 Nov 2004 17:12:43 +0100 Pierre-Frédéric Caillaud [EMAIL PROTECTED] wrote: WHERE cd='ca' ORDER BY l_postcode; Write : WHERE cd='ca' ORDER BY cd, l_postcode; You have a multicolumn index, so you should specify a multicolumn sort exactly the same as

[PERFORM] Index usage for sorted query

2004-11-20 Thread Markus Schaber
Hello, I have the following query plan: logigis=# explain SELECT geom, ref_in_id as ref, nref_in_id as nref, st_name as name, substr(l_postcode,1,2) as postfirst, func_class as level FROM schabi.streets WHERE cd='ca' ORDER BY l_postcode; QUERY PLAN

Re: [PERFORM] Index usage for sorted query

2004-11-20 Thread Pierre-Frdric Caillaud
Instead of : WHERE cd='ca' ORDER BY l_postcode; Write : WHERE cd='ca' ORDER BY cd, l_postcode; You have a multicolumn index, so you should specify a multicolumn sort exactly the same as your index, and the planner will get it. ---(end of

Re: [PERFORM] Index usage for sorted query

2004-11-20 Thread Tom Lane
Markus Schaber [EMAIL PROTECTED] writes: But as it fetches all the rows through the index, why doesn't it recognize that, fetching this way, the rows are already sorted by l_postcode? Tell it to ORDER BY cd, l_postcode. Is Postgresql 8 more intelligend in this case? No.

Re: [PERFORM] index usage

2004-04-28 Thread scott.marlowe
On Mon, 26 Apr 2004, Stephan Szabo wrote: On Fri, 23 Apr 2004 [EMAIL PROTECTED] wrote: I have a query which I think should be using an index all of the time but postgres only uses the index part of the time. The index (ticket_crm_map_crm_id_suppid) has the where clause column (crm_id)

Re: [PERFORM] index usage

2004-04-28 Thread Tom Lane
scott.marlowe [EMAIL PROTECTED] writes: There are tons of hints that it works this way in how they're written, but nothing that just comes out and says that with pgsql's mvcc implementation, an index scan still has to hit the pages that contain the tuples, so often in pgsql a seq scan is a

[PERFORM] index usage

2004-04-26 Thread brad-pgperf
Hi, I have a query which I think should be using an index all of the time but postgres only uses the index part of the time. The index (ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed first followed by the selected column (support_person_id). Wouldn't the most

Re: [PERFORM] index usage

2004-04-26 Thread brad-pgperf
When checking an index in postgres the original table has to be checked for each result to find if the index entry is still valid? In which case you can't blindly scan the whole index and assume the data is good. I was used to Oracle behavior where the index is up to date so it can do the scan