Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

PostgreSQL indeterminate ordering of results [on hold]

$
0
0

When I have this query:

SELECT DISTINCT "spree_products".id FROM "spree_products"
INNER JOIN "spree_variants"
   ON "spree_variants"."product_id" = "spree_products"."id"
  AND "spree_variants"."is_master" = 't'
INNER JOIN "spree_prices"
   ON "spree_prices"."variant_id" = "spree_variants"."id"
INNER JOIN "spree_products_taxons"
   ON "spree_products_taxons"."product_id" = "spree_products"."id" 
INNER JOIN "spree_taxons"
   ON "spree_taxons"."id" = "spree_products_taxons"."taxon_id"
WHERE "spree_taxons"."id" IN (13)
AND "spree_prices"."currency" = 'USD'
AND ("spree_products".deleted_at IS NULL
  or "spree_products".deleted_at >= '2013-08-30 06:23:45.881488')
AND ("spree_products".available_on <= '2013-08-30 06:23:45.881974')
AND (spree_prices.amount IS NOT NULL) LIMIT 12 OFFSET 36

I get some records returned in different offsets. For example, I see a record with ID=53 in both OFFSET 24 and OFFSET 36.

If I add an ORDER BY spree_products.id clause to this statement, it makes the order determinate and I never see the same record returned in different offsets.


Viewing all articles
Browse latest Browse all 1138

Trending Articles