From: | "Andrus" <kobruleht2(at)hot(dot)ee> |
---|---|
To: | "Jim Nasby" <Jim(dot)Nasby(at)BlueTreble(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to find greatest record before known values fast |
Date: | 2014-10-03 06:28:57 |
Message-ID: | C2F1B84DC3F14AFD96F3132C78991CEB@dell2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
>So kellaaeg is a time? Your best bet here would be to create an index that
>is an actual timestamp comprised of both >kuupaev and kellaaeg. You could
>do this with to_timestamp by concatinating both fields together, or it may
>be easier to replace the space in kellaaeg with a colon and cast it to
>time, then add the two:
> kuupaev + replace( kellaaeg, ' ', ':' )::time
>I know you can't alter the table, but can you create a view on top of the
>table? If you did that, you could have a real >timestamp field in the view
>that is calculated from kuupaev and kellaaeg and you can create a
>functional index that >uses the same calculation. That would be the easiest
>way to use this.
Thank you.
I solved this by creating composite index on 3 columns and re-writing query
as Tom recommended.
It looks like Tom's recommendation is simpler for me.
Andrus.
From | Date | Subject | |
---|---|---|---|
Next Message | Cedric Berger | 2014-10-03 07:31:54 | Re: Getting my Database name in a C Extension |
Previous Message | Michael Paquier | 2014-10-03 04:40:19 | Re: Creating a PL/pgSQL function that returns multiple out parameters and refcursor |