Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
1 answer
269 views

Emulate Loose Index Scan for multiple columns with alternating sort direction

A while back I asked this question about efficiently selecting unique permutations of columns in Postgres. Now I have a follow-up question regarding how to do so, with the addition of being able to ...
hunter's user avatar
  • 197
0 votes
1 answer
2k views

Use skip scan index to efficiently select unique permutations of columns in Postgres

I've already read this excellent answer for emulating skip scan index to retrieve the distinct values for a single column. This is blazingly fast. Now what I'm trying to do is to retrieve unique ...
hunter's user avatar
  • 197
2 votes
1 answer
2k views

Best performance to get distinct values for a given key from a big table

Given a table like so: CREATE TABLE attr (user_id uuid, key text, value text); with indexes on key and value (but not a combined index) what are my options for getting a list of distinct values by ...
Chris Cooper's user avatar
0 votes
1 answer
221 views

How to query results from a huge postgres database?

I am trying to query a few tables in a 125GB Postgres database. I find a hard time getting the results back quickly! Even to find unique rows of a column it takes more than 10 minutes. Either I use a ...
Anu's user avatar
  • 105
0 votes
1 answer
3k views

Distinct counts from large table are too slow

I have a table with 1.2 billion rows. The table has 60-70 columns, the vast majority of which are empty. The table is indexed on subscription_id, among other indexes. My query is: SELECT count(...
RubyRedGrapefruit's user avatar
6 votes
1 answer
2k views

Fastest query for distinct IDs in a many-to-many relationship

I have this table in PostgreSQL 9.4: CREATE TABLE user_operations( id SERIAL PRIMARY KEY, operation_id integer, user_id integer ) The table consists of ~1000-2000 different operations ...
St.Antario's user avatar
  • 1,275
28 votes
5 answers
90k views

SELECT DISTINCT on multiple columns

Supposing we have a table with four columns (a,b,c,d) of the same data type. Is it possible to select all distinct values within the data in the columns and return them as a single column or do I ...
Fabrizio Mazzoni's user avatar