Skip to content
Advertisement

Tag: postgresql

Optimize BETWEEN date statement

I need help optimizing a Postgres query which uses the BETWEEN clause with a timestamp field. I have 2 tables: containing about 3394 rows containing about 4000000 rows There are btree indexes on both PKs id_one and id_two, on the FK id_one and cut_time. I want to perform a query like: This query retrieves about 1.700.000 rows in about 7

Pivot on Multiple Columns using Tablefunc

Has anyone used tablefunc to pivot on multiple variables as opposed to only using row name? The documentation notes: The “extra” columns are expected to be the same for all rows with the same row_name value. I’m not sure how to do this without combining the columns that I want to pivot on (which I highly doubt will give me

how to execute a .sql script on heroku?

I have a .sql file with a bunch of insert commands that I want to execute on my postgres database on heroku. But I don’t know how to do it:- If I had access to postgres console I’d type the following: but it seems that heroku doesn’t support this command. I’ve tried with but that doesn’t let me input a

Text to List in SQL

Is there any way on how to convert a comma separated text value to a list so that I can use it with ‘IN’ in SQL? I used PostgreSQL for this one. Ex.: This query: produces ‘SG’,’PH’ I wanted to produce this query: Nothing returned when I executed the first query. The table has been filled with location values ‘SG’

Advertisement