Re: [PERFORM] Poor query plan chosen in 9.0.3 vs 8.3.7

2011-05-05 Thread Bosco Rama
Hey Brian,

Brian Connolly wrote:
> (I had to send a follow up email due the length of email restrictions on the
> mailing list.)

A tip for when you have this problem in the future -- turn off html mail.
It will reduce your email message length by 50% - 90%.

HTH

Bosco.

-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


Re: [PERFORM] cluster on conditional index?

2012-08-15 Thread Bosco Rama
On 08/15/12 14:05, Josh Berkus wrote:
> 
>> That actually makes sense to me. Cluster the rows covered by that
>> index, let the rest fall where they may. I'm typically only accessing
>> the rows covered by that index, so I'd get the benefit of the cluster
>> command but wouldn't have to spend cycles doing the cluster for rows I
>> don't care about.
> 
> Sure, that's a feature request though.  And thinking about it, I'm
> willing to bet that it's far harder to implement than it sounds.
> 
> In the meantime, you could ad-hoc this by splitting the table into two
> partitions and clustering one of the two partitions.

Wouldn't creating a second index on the boolean itself and then clustering
on that be much easier?

Bosco.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


Re: [PERFORM] Fastest way / best practice to calculate "next birthdays"

2015-05-21 Thread Bosco Rama
On 05/20/15 20:22, David G. Johnston wrote:
> On Monday, May 18, 2015, er.tejaspate...@gmail.com <
> er.tejaspate...@gmail.com> wrote:
> 
>> If I have to find upcoming birthdays in current week and the current week
>> fall into different months - how would you handle that?
>>
> 
> Extract(week from timestamptz_column)
> 
> ISO weeks are not affected by month boundaries but do start on Monday.

There is the year start/end boundary conditions to worry about there.

If the current week covers Dec28-Jan02 then week of year won't help for
a birthday on Jan01 or Jan02 if 'today' is in the Dec portion.  Ditto
for birthday in Dec portion when 'today' is in the Jan portion.

There is probably a better way to do it than what I'm showing here, but
here's an example:

with x as (
   select now() - (extract(dow from now()) || ' days')::interval as
weekstart
)
select to_char(x.weekstart, '-MM-DD') as first_day,
to_char(x.weekstart + '6 days', '-MM-DD') as last_day
from x;

You could probably make some of that into a function that accepts a
timestamptz and generates the two days.  Or even does the compare too.

HTH.

Bosco.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance