Re: [PERFORM] Index usage for tstzrange?

2013-03-22 Thread Tom Lane
Heikki Linnakangas 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 approximately everything

Re: [PERFORM] Index usage for tstzrange?

2013-03-22 Thread Josh Berkus
> We should do this automatically. Or am I missing something? Aside from the need to support @> as well, not that I can see. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subsc

Re: [PERFORM] Index usage for tstzrange?

2013-03-22 Thread Heikki Linnakangas
On 22.03.2013 02:05, Josh Berkus wrote: 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. Y

Re: [PERFORM] Index usage for tstzrange?

2013-03-22 Thread Heikki Linnakangas
On 21.03.2013 17:55, Alexander Korotkov wrote: On Thu, Mar 21, 2013 at 12:52 PM, Heikki Linnakangas< The immediate fix is attached, but this made me realize that rangesel() is still missing estimation for the "element<@ range" operator. It shouldn't be hard to implement, I'm pretty sure we have

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.

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 Lane 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'); ERROR: XX000: type 11

Re: [PERFORM] Index usage for tstzrange?

2013-03-20 Thread Vasilis Ventirozos
On Thu, Mar 21, 2013 at 5:58 AM, Tom Lane wrote: > Josh Berkus 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 > > ); >

Re: [PERFORM] Index usage for tstzrange?

2013-03-20 Thread Tom Lane
Josh Berkus 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 <@ tstzrange('2013-

[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 00:10:

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

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 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=#

[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 on queries on inherited tables

2011-04-29 Thread Robert Haas
On Apr 27, 2011, at 11:11 PM, Joseph Shraibman 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 enable_seqscan=off. >

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

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 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 enable_seqscan=of

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 Robert Haas
On Fri, Apr 1, 2011 at 2:41 AM, Joseph Shraibman 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 ; >                

[PERFORM] index usage on queries on inherited tables

2011-03-31 Thread Joseph Shraibman
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 ; QUERY PLAN

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

2010-07-09 Thread Jeremy Palmer
eremy Palmer Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Index usage with functions in where condition Jeremy Palmer 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 -

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

2010-07-09 Thread Tom Lane
Jeremy Palmer 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 -41.0618-degrees(

[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 followi

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 reaso

Re: [PERFORM] index usage in not like

2010-02-18 Thread Thom Brown
On 18 February 2010 12:18, A. Kretschmer wrote: > In response to Thom Brown : >> On 18 February 2010 11:55, AI Rumman wrote: >> > "Not like" operation does not use index. >> > >> > select * from vtiger_contactscf where lower(cf_1253) not like >> > lower('Former%') >> > >> > I created index on low

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 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 A. Kretschmer
In response to Thom Brown : > On 18 February 2010 11:55, AI Rumman 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 l

Re: [PERFORM] index usage in not like

2010-02-18 Thread Thom Brown
> On Thu, Feb 18, 2010 at 6:00 PM, Thom Brown wrote: >> >> On 18 February 2010 11:55, AI Rumman 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). >> > >> >

Re: [PERFORM] index usage in not like

2010-02-18 Thread Thom Brown
On 18 February 2010 11:55, AI Rumman 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. > How ma

[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 with sub select or outer joins

2008-11-12 Thread Julien Theulier
-Message d'origine- De : Joshua Tolley [mailto:[EMAIL PROTECTED] Envoyé : mercredi 12 novembre 2008 14:54 À : 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 Theul

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, >

[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, vi_pv_id,a.i

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

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 D

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

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 pa

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

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 con

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

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: >> 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

Re: [PERFORM] Index usage problem on 8.3.3

2008-10-30 Thread Jeff Frost
Tom Lane wrote: > 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? >

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

[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' a

[PERFORM] index usage makes problem

2008-03-06 Thread sathiya psql
I had 50 lakh records in my table... while counting that am using that row in where condition... which makes problem, cpu is waiting for device... Debian OS, postresql 7.4, 50 lakh records. Query is EXPLAIN ANALYZE select count(call_id) from call_log where call_id > 1; while seeing the top, cp

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 match

[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 the

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 vers

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 fals

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 w

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 >

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 & > T

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

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 btre

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

2007-09-16 Thread Kevin Grittner
>>> On Thu, Sep 13, 2007 at 7:30 AM, in message <[EMAIL PROTECTED]>, "W.Alphonse HAROUNY" <[EMAIL PROTECTED]> wrote: >and each binary value of [variableCategory] may only hold a single binary > '1'. > TBL1.CATEGORY & TBL2.CATEGORY <> 0 //-- where & is the AND bitwise > operator What abou

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

2007-09-16 Thread Valentine Gogichashvili
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 btre

[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 . ; }

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 lat

[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... Execution

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

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

[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-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, t

Re: [PERFORM] index usage

2006-07-28 Thread Mark Lewis
t 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@pos

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 usa

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 o

[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 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 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) > > T

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

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

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: SELEC

[PERFORM] Index Usage using IN

2006-02-01 Thread Ralph Mason
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 generates sequential scans. Table A has about 250,000 rows. Table B has about 250,00

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

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 for sorted query

2004-11-20 Thread Pierre-Frédéric 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 broadcast)

[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

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 sca

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

Re: [PERFORM] index usage

2004-04-26 Thread Stephan Szabo
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) listed > first followed by the selected column

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

[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 effi