Is it possible to create row-wise indexable condition for special case...

From: Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Is it possible to create row-wise indexable condition for special case...
Date: 2012-08-06 05:39:08
Message-ID: CAK-MWwQ-Pn9NvLZZSpmUxjbP-3HeEH2T4+6FAdX5h1bX7VXpmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I know that for condition like ((field1>value1) or (field1=value1 and
field2>value2)) I could built index on (field1, field2) and use indexable
condition like (field1, field2) > (value1, value2).

However, I have very tricky query which requires an indexable condition
like (field1>value1) or (field1=value1 and field2<value2).
I guess that I could use index definition like ON(field1, field2 DESC)
however, I can not build query condition which would use that index
effectively.

Is it possible and my mind just went black on simple task?

PS: field2 is varchar type so I couldn't using the negative values trick
build index ON(field1, (-field2))
and write something like WHERE (field1, -field2) > (value1, -value2).

--
Maxim Boguk
Senior Postgresql DBA
http://www.postgresql-consulting.ru/ <http://www.postgresql-consulting.com/>

Phone RU: +7 910 405 4718
Phone AU: +61 45 218 5678

Skype: maxim.boguk
Jabber: maxim(dot)boguk(at)gmail(dot)com
МойКруг: http://mboguk.moikrug.ru/

"People problems are solved with people.
If people cannot solve the problem, try technology.
People will then wish they'd listened at the first stage."

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stuart Bishop 2012-08-06 07:55:02 Streaming replication failover with 3 servers
Previous Message Mike Christensen 2012-08-06 02:56:47 Re: Is this a Postgres Bug?