> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Wednesday, May 29, 2002 9:07 AM
> To: Jan Wieck
> Cc: Oleg Bartunov; Teodor Sigaev; pgsql-hackers@postgresql.org
> Subject: Re: [HACKERS] Null values in indexes 
> 
> 
> Jan Wieck <janwieck@yahoo.com> writes:
> > Tom Lane wrote:
> >> Hannu Krosing <hannu@tm.ee> writes:
> > How hard would it be to _not_ include nulls in indexes
> > as they are not used anyway.
> >> 
> >> Seems to me that would be a step backwards.
> 
> >     It  would cause multi-key indexes beeing unusable for partial
> >     key lookup. Imagine you have a key over (a, b, c)  and  query
> >     with  WHERE  a = 1 AND b = 2. This query cannot use the index
> >     if a NULL value in c  would  cause  the  index  entry  to  be
> >     suppressed.
> 
> Urgh ... that means GiST indexing is actually broken, because GiST
> currently handles multicolumns but not nulls.  AFAIR the planner
> will try to use partial qualification on any multicolumn index...
> it had better avoid doing so for non-null-capable AMs.
> 
> Alternatively, we could fix GiST to support nulls.  Oleg, Teodor:
> how far away might that be?

The PostGIS people have already fixed it.  However, they may not be
willing to contribute the patch.  On the other hand, I think it would be
in their interest, since the source code trees will fork if they don't
and they will have trouble staying in synch with PostgreSQL
developments.  (See the 7.2 index project here:
http://postgis.refractions.net/ 
http://postgis.refractions.net/news/index.php?file=20020425.data
)

If they are not willing to commit a patch, I suspect that they will at
least tell you what they had to do to fix it and it could be performed
internally.

Wed, 29 May 2002 10:00:03 -0700
"Dann Corbit" <DCorbit@connx.com>
Re: Null values in indexes 
Just to clarify:

- With respect to null safety. My understanding is the Oleg and Teodor
put support for nulls into the GiST indexing prior to the 7.2 release,
so 7.2 GiST should already be null-safe. Our project was just to take
our GiST bindings in PostGIS and update them to the new 7.2 GiST API, we
did no work on null-safety, null-safety was just one of the side
benefits we received as a result of updating our code to the 7.2 GiST
indexes.

- With respect to code contribution. If we find ourselves making changes
to the mainline PgSQL distribution we will always submit back. End of
story. All our changes have been to PostGIS itself, with the aim of
supporting 7.2. 7.2 rocks, we love it. :)

- There is one outstanding bug which we identified and Oleg and Teodor
fixed, but it is to the code in contrib/rtree, not in the mainline, and
Oleg and Teodor have already submitted that patch to Bruce. I believe
there was some unresolved discussion regarding whether to cut a 7.2.2
release including that patch and a few other housekeeping items.

Paul


Dann Corbit wrote:
> 
> > -----Original Message-----
> > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> > Sent: Wednesday, May 29, 2002 9:07 AM
> > To: Jan Wieck
> > Cc: Oleg Bartunov; Teodor Sigaev; pgsql-hackers@postgresql.org
> > Subject: Re: [HACKERS] Null values in indexes
> >
> >
> > Jan Wieck <janwieck@yahoo.com> writes:
> > > Tom Lane wrote:
> > >> Hannu Krosing <hannu@tm.ee> writes:
> > > How hard would it be to _not_ include nulls in indexes
> > > as they are not used anyway.
> > >>
> > >> Seems to me that would be a step backwards.
> >
> > >     It  would cause multi-key indexes beeing unusable for partial
> > >     key lookup. Imagine you have a key over (a, b, c)  and  query
> > >     with  WHERE  a = 1 AND b = 2. This query cannot use the index
> > >     if a NULL value in c  would  cause  the  index  entry  to  be
> > >     suppressed.
> >
> > Urgh ... that means GiST indexing is actually broken, because GiST
> > currently handles multicolumns but not nulls.  AFAIR the planner
> > will try to use partial qualification on any multicolumn index...
> > it had better avoid doing so for non-null-capable AMs.
> >
> > Alternatively, we could fix GiST to support nulls.  Oleg, Teodor:
> > how far away might that be?
> 
> The PostGIS people have already fixed it.  However, they may not be
> willing to contribute the patch.  On the other hand, I think it would be
> in their interest, since the source code trees will fork if they don't
> and they will have trouble staying in synch with PostgreSQL
> developments.  (See the 7.2 index project here:
> http://postgis.refractions.net/
> http://postgis.refractions.net/news/index.php?file=20020425.data
> )
> 
> If they are not willing to commit a patch, I suspect that they will at
> least tell you what they had to do to fix it and it could be performed
> internally.

-- 
      __
     /
     | Paul Ramsey
     | Refractions Research
     | Email: pramsey@refractions.net
     | Phone: (250) 885-0632
     \_

Wed, 29 May 2002 10:16:06 -0700
Paul Ramsey <pramsey@refractions.net>
Re: Null values in indexes
>> Urgh ... that means GiST indexing is actually broken, because GiST
>> currently handles multicolumns but not nulls.

Actually, it appears that 7.2 GiST does handle NULLs in columns after
the first one, which I think is enough to avoid the problem Jan
mentioned.  The boolean column pg_am.amindexnulls is not really
sufficient to describe this behavior accurately.  Looking at current
uses it seems correct to leave it set FALSE for GiST.

In short: false alarm; the 7.2 code is okay as-is, at least on this
particular point.

			regards, tom lane

Wed, 29 May 2002 13:21:37 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Null values in indexes 
Hmm... I think there is some confusion here.

Oleg and Teodor updated the GiST indexing to be null safe for postgresql 7.2. 
The changes we made to PostGIS were just to allow our spacial indexing 
support functions to work with the changes made in the actual GiST indexing 
code (the GiST interface changed somewhat from postgresql 7.1 -> 7.2).

And for the record, I'm confident that we would submit a patch for postgresql 
if something like this did come up.

Chris Hodgson

Dann Corbit <DCorbit@connx.com> said:

> > -----Original Message-----
> > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> > Sent: Wednesday, May 29, 2002 9:07 AM
> > To: Jan Wieck
> > Cc: Oleg Bartunov; Teodor Sigaev; pgsql-hackers@postgresql.org
> > Subject: Re: [HACKERS] Null values in indexes 
> > 
> > 
> > Jan Wieck <janwieck@yahoo.com> writes:
> > > Tom Lane wrote:
> > >> Hannu Krosing <hannu@tm.ee> writes:
> > > How hard would it be to _not_ include nulls in indexes
> > > as they are not used anyway.
> > >> 
> > >> Seems to me that would be a step backwards.
> > 
> > >     It  would cause multi-key indexes beeing unusable for partial
> > >     key lookup. Imagine you have a key over (a, b, c)  and  query
> > >     with  WHERE  a = 1 AND b = 2. This query cannot use the index
> > >     if a NULL value in c  would  cause  the  index  entry  to  be
> > >     suppressed.
> > 
> > Urgh ... that means GiST indexing is actually broken, because GiST
> > currently handles multicolumns but not nulls.  AFAIR the planner
> > will try to use partial qualification on any multicolumn index...
> > it had better avoid doing so for non-null-capable AMs.
> > 
> > Alternatively, we could fix GiST to support nulls.  Oleg, Teodor:
> > how far away might that be?
> 
> The PostGIS people have already fixed it.  However, they may not be
> willing to contribute the patch.  On the other hand, I think it would be
> in their interest, since the source code trees will fork if they don't
> and they will have trouble staying in synch with PostgreSQL
> developments.  (See the 7.2 index project here:
> http://postgis.refractions.net/ 
> http://postgis.refractions.net/news/index.php?file=20020425.data
> )
> 
> If they are not willing to commit a patch, I suspect that they will at
> least tell you what they had to do to fix it and it could be performed
> internally.
> 
> 



-- 




Wed, 29 May 2002 17:22:16 -0000
"Chris Hodgson" <chodgson@refractions.net>
Re: Null values in indexes 
Glad to hear GiST in 7.2 isn't broken :-)
We miss the topic, what was the problem ?
Do we need to fix GiST code for 7.3 ?

proposal for null-safe GiST interface is available
http://fts.postgresql.org/db/mw/msg.html?mid=1028327
and discussion
http://fts.postgresql.org/db/mw/msg.html?mid=1025848


	Regards,
		Oleg
On Wed, 29 May 2002, Tom Lane wrote:

> >> Urgh ... that means GiST indexing is actually broken, because GiST
> >> currently handles multicolumns but not nulls.
>
> Actually, it appears that 7.2 GiST does handle NULLs in columns after
> the first one, which I think is enough to avoid the problem Jan
> mentioned.  The boolean column pg_am.amindexnulls is not really
> sufficient to describe this behavior accurately.  Looking at current
> uses it seems correct to leave it set FALSE for GiST.
>
> In short: false alarm; the 7.2 code is okay as-is, at least on this
> particular point.
>
> 			regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

	Regards,
		Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


Thu, 30 May 2002 13:13:13 +0300 (GMT)
Oleg Bartunov <oleg@sai.msu.su>
Re: Null values in indexes 
Oleg Bartunov <oleg@sai.msu.su> writes:
> Do we need to fix GiST code for 7.3 ?

No, I think it's fine.  I had forgotten that old discussion ...

			regards, tom lane

Thu, 30 May 2002 09:57:25 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Null values in indexes 