Skip to main content
Rollback to Revision 8
Source Link
pacmaninbw
  • 26.1k
  • 13
  • 47
  • 114

Edit: Edit:
I must confess, I'm not really familiarended up with SQL, I tried to write a query which includes alsoloads the sorting, order and limit. I cam out with followings:

WITH result_set 
AS (
   SELECT {prefix}.id AS mainId, ROW_NUMBER () OVER (PARTITION BY {prefix}.id), {query} ORDER BY {orderBy} {order}
) 
SELECT mainId 
FROM result_set 
WHERE row_number = 1 
OFFSET {offset} 
LIMIT {paginationOptions.ItemsPerPage}

It workspaged data in 2, but the performance on the same2sec over a table with 1mil rows, dropped to 8sec. I fear ROW_NUMBER is responsible for.
In fact I have a dynamic query, in theIs it an acceptable result I need just the ordered ids. How can I improve the query?

Edit:
I must confess, I'm not really familiar with SQL, I tried to write a query which includes also the sorting, order and limit. I cam out with followings:

WITH result_set 
AS (
   SELECT {prefix}.id AS mainId, ROW_NUMBER () OVER (PARTITION BY {prefix}.id), {query} ORDER BY {orderBy} {order}
) 
SELECT mainId 
FROM result_set 
WHERE row_number = 1 
OFFSET {offset} 
LIMIT {paginationOptions.ItemsPerPage}

It works, but the performance on the same table with 1mil rows, dropped to 8sec. I fear ROW_NUMBER is responsible for.
In fact I have a dynamic query, in the result I need just the ordered ids. How can I improve the query?

Edit:
I ended up with a query which loads the paged data in 2,2sec over a table with 1mil rows. Is it an acceptable result?

Rollback to Revision 5
Source Link
pacmaninbw
  • 26.1k
  • 13
  • 47
  • 114

Edit:Edit:
I ended upmust confess, I'm not really familiar with SQL, I tried to write a query which loadsincludes also the paged data in 2sorting,2sec over a order and limit. I cam out with followings:

WITH result_set 
AS (
   SELECT {prefix}.id AS mainId, ROW_NUMBER () OVER (PARTITION BY {prefix}.id), {query} ORDER BY {orderBy} {order}
) 
SELECT mainId 
FROM result_set 
WHERE row_number = 1 
OFFSET {offset} 
LIMIT {paginationOptions.ItemsPerPage}

It works, but the performance on the same table with 1mil rows, dropped to 8sec. Is it an acceptableI fear ROW_NUMBER is responsible for.
In fact I have a dynamic query, in the result I need just the ordered ids. How can I improve the query?

Edit:
I ended up with a query which loads the paged data in 2,2sec over a table with 1mil rows. Is it an acceptable result?

Edit:
I must confess, I'm not really familiar with SQL, I tried to write a query which includes also the sorting, order and limit. I cam out with followings:

WITH result_set 
AS (
   SELECT {prefix}.id AS mainId, ROW_NUMBER () OVER (PARTITION BY {prefix}.id), {query} ORDER BY {orderBy} {order}
) 
SELECT mainId 
FROM result_set 
WHERE row_number = 1 
OFFSET {offset} 
LIMIT {paginationOptions.ItemsPerPage}

It works, but the performance on the same table with 1mil rows, dropped to 8sec. I fear ROW_NUMBER is responsible for.
In fact I have a dynamic query, in the result I need just the ordered ids. How can I improve the query?

deleted 680 characters in body
Source Link

Edit:
I ended up with a query which loads the paged data in 2,2sec over a table with 1mil rows. Is it an acceptable result?

Edit:
I ended up with a query which loads the paged data in 2,2sec over a table with 1mil rows. Is it an acceptable result?

deleted 680 characters in body
Source Link
Loading
added 2 characters in body
Source Link
Loading
added 676 characters in body
Source Link
Loading
edited body
Source Link
Loading
deleted 252 characters in body
Source Link
Loading
deleted 5 characters in body
Source Link
Loading
Source Link
Loading