Skip to main content
add links, plus notes on index
Source Link
Erwin Brandstetter
  • 182.1k
  • 28
  • 457
  • 620

Notably, you added user_id as 3rd expression to ORDER BY to break ties. That's good. But if you want to keep using Row Constructor Comparison, all 3 expressions must share the same sort direction. All ASCENDING or all DESCENDING. Else(Else it gets more complex and expensive.
Also) See:

Also, add user_id to the SELECT list. It's essential for your pagination.

'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity. (I added it in the fiddle.)

Since your date_bin() expression uses an arbitrary time anchor (and interval?), using an index is sophisticated, but still possible. Work with the lower / upper bounds of possible date_bin() values ...

Notably, you added user_id as 3rd expression to ORDER BY to break ties. That's good. But if you want to keep using Row Constructor Comparison, all 3 expressions must share the same sort direction. All ASCENDING or all DESCENDING. Else it gets more complex and expensive.
Also, add user_id to the SELECT list. It's essential for your pagination.

'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity. (I added it in the fiddle.)

Notably, you added user_id as 3rd expression to ORDER BY to break ties. That's good. But if you want to keep using Row Constructor Comparison, all 3 expressions must share the same sort direction. All ASCENDING or all DESCENDING. (Else it gets more complex and expensive.) See:

Also, add user_id to the SELECT list. It's essential for your pagination.

'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity. (I added it in the fiddle.)

Since your date_bin() expression uses an arbitrary time anchor (and interval?), using an index is sophisticated, but still possible. Work with the lower / upper bounds of possible date_bin() values ...

Clarify timestamp, update fiddle
Source Link
Erwin Brandstetter
  • 182.1k
  • 28
  • 457
  • 620

fiddle

('2023-03-25 00:11:56+01', 8, 5) being derived from the last row of the first page.
  

'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity. (I added it in the fiddle.)

fiddle These two timestamptz values are exactly the same:

'2023-03-24 23:11:56+00'
'2023-03-25 00:11:56+01'

The display depends on the timezone setting of your session, the value is the same. Basics:

('2023-03-25 00:11:56+01', 8, 5) being derived from the last row of the first page.
 '2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity.

fiddle

fiddle

('2023-03-25 00:11:56+01', 8, 5) being derived from the last row of the first page. 

'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity. (I added it in the fiddle.)

These two timestamptz values are exactly the same:

'2023-03-24 23:11:56+00'
'2023-03-25 00:11:56+01'

The display depends on the timezone setting of your session, the value is the same. Basics:

clarify
Source Link
Erwin Brandstetter
  • 182.1k
  • 28
  • 457
  • 620

('2023-03-25 00:11:56+01', 8, 5) being derived from the last row of the first page.
'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity.

('2023-03-25 00:11:56+01', 8, 5) being derived from the last row of the first page.

('2023-03-25 00:11:56+01', 8, 5) being derived from the last row of the first page.
'2023-03-25 00:11:56+01' is the result of the date_bin() expression. You might add it to the SELECT list for simplicity.

Source Link
Erwin Brandstetter
  • 182.1k
  • 28
  • 457
  • 620
Loading