Обсуждение: Configure default for sorting of null-values?
Hi, From the docs I see that you can control null values being sorted before or after all non-null-values using 'NULLS LAST' or 'NULLS FIRST' in the order by clause. The default behaviour is to act as though nulls are larger than non-nulls. My question is, is there a way to configure this default, at connection level or at server level? Thanks, Rob
Does anyone know if this is configurable? Or should I file a feature request? Rob On Wed, Sep 1, 2010 at 10:05 AM, Rob Gansevles <rgansevles@gmail.com> wrote: > Hi, > > From the docs I see that you can control null values being sorted > before or after all non-null-values using 'NULLS LAST' or 'NULLS > FIRST' in the order by clause. > > The default behaviour is to act as though nulls are larger than non-nulls. > > My question is, is there a way to configure this default, at > connection level or at server level? > > Thanks, > > Rob >
Le 07/09/2010 09:57, Rob Gansevles a écrit : > Does anyone know if this is configurable? > You can only add that clause in the order by. There's no way to have a "default value" at connection time or as a server configuration parameter. -- Guillaume http://www.postgresql.fr http://dalibo.com
Rob Gansevles <rgansevles@gmail.com> writes: > Does anyone know if this is configurable? > Or should I file a feature request? It is not, and a feature request is probably going to go nowhere. The reason configurability seems like a bad idea is that null sort direction is wired into things like index contents. If a user were to flip the default null sort direction locally to his session, then suddenly most of the indexes in the system would become unusable to him. No doubt there are things that could be done to ameliorate that, but overall it's just not apparent that the cost/benefit ratio is reasonable for such a change. regards, tom lane
On 7/09/2010 10:32 PM, Tom Lane wrote: > Rob Gansevles<rgansevles@gmail.com> writes: >> Does anyone know if this is configurable? >> Or should I file a feature request? > > It is not, and a feature request is probably going to go nowhere. > The reason configurability seems like a bad idea is that null sort > direction is wired into things like index contents. It'd probably have to be done at CREATE DATABASE time, like the setup of the database encoding is. Personally I can't say I really see the point. I suspect database designs that rely on the sort order of NULL anyway - they usually seem to be trying to use null as a concrete value rather than an "unset/unknown". Even if that's not the case here, I suspect (OP) that you'd have to produce a viable patch for this feature if you want it supported, as I doubt there'll be enough interest for anyone else to want to implement it. -- Craig Ringer Tech-related writing at http://soapyfrogs.blogspot.com/