Closed giangpham712 closed 1 year ago
Hello, I am Blathers. I am here to help you get the issue triaged.
Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.
I have CC'd a few people who may be able to assist you:
If we have not gotten back to your issue within a few business days, you can try the following:
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
Hi @giangpham712, thanks for the report. A different first row is returned because the queries have no ordering specified. Since the query with a LIMIT
has no ordering, CRDB is free to return any single row that satisfies the WHERE
clause. If you add the same ordering to your queries, the first row should be the same as you expect:
SELECT o."OrderID", o."OrderDate"
FROM "Orders" AS o
WHERE o."CustomerID" IS NOT NULL AND o."CustomerID" LIKE 'F%'
ORDER BY o."OrderID";
SELECT o."OrderID", o."OrderDate"
FROM "Orders" AS o
WHERE o."CustomerID" IS NOT NULL AND o."CustomerID" LIKE 'F%'
ORDER BY o."OrderID"
LIMIT 1;
As an additional detail, the ordering needs to be unique on the query output columns; otherwise, the ordering of rows with duplicate values in the ordering columns will be unpredictable.
I agree with everything Drew said, so closing as expected behavior.
Describe the problem
Given a table
with some data
The following query
returns
while a similar query with LIMIT
returns
The first row is different
Additional context What was the impact?
This affects efcore.pg tests
Jira issue: CRDB-31568