The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: temporary remove default sorting (#28072)
Jonathan Summers-Muira4b4167a5b13
diff --git a/apps/studio/data/table-rows/table-rows-query.ts b/apps/studio/data/table-rows/table-rows-query.tsindex d399b6717d0..ee0c84c4580 100644--- a/apps/studio/data/table-rows/table-rows-query.ts+++ b/apps/studio/data/table-rows/table-rows-query.ts@@ -73,17 +73,26 @@ export const fetchAllTableRows = async ({queryChains = queryChains.filter(filter.column, filter.operator, value)})+ /**+ * [Joshen] JFYI 190724 We've commented the default sort logic out below and in getTableRowsSqlQuery+ * as the default sort causes resource issues in particular for very large tables (e.g 200M rows)+ * The long term fix here should be to only apply default sort if table has < 50k rows+ * - this is the same threshold that we do for retrieving the exact count on the table (ref table-rows-count-query)+ * - we can check the estimate row count when we get the table details via pg-meta under the live_rows_estimate property+ * - i.e the larger the table, the less hand holding the table editor does (which i think is fair from a scalability pov)+ */+// If sorts is empty, use the primary key as the default sort- if (sorts.length === 0) {- const primaryKey = getDefaultOrderByColumn(table)- if (primaryKey) {- queryChains = queryChains.order(table.name, primaryKey, true, true)- }- } else {- sorts.forEach((sort) => {- queryChains = queryChains.order(sort.table, sort.column, sort.ascending, sort.nullsFirst)- })- }+ // if (sorts.length === 0) {+ // const primaryKey = getDefaultOrderByColumn(table)+ // if (primaryKey) {+ // queryChains = queryChains.order(table.name, primaryKey, true, true)+ // }+ // } else {+ sorts.forEach((sort) => {+ queryChains = queryChains.order(sort.table, sort.column, sort.ascending, sort.nullsFirst)+ })+ // }// Starting from page 0, fetch 500 records per calllet page = -1@@ -144,17 +153,17 @@ export const getTableRowsSqlQuery = ({})// If sorts is empty, use the primary key as the default sort- if (sorts.length === 0) {- const defaultOrderByColumn = getDefaultOrderByColumn(table)-- if (defaultOrderByColumn) {- queryChains = queryChains.order(table.name, defaultOrderByColumn, true, true)- }- } else {- sorts.forEach((x) => {- queryChains = queryChains.order(x.table, x.column, x.ascending, x.nullsFirst)- })- }+ // if (sorts.length === 0) {+ // const defaultOrderByColumn = getDefaultOrderByColumn(table)++ // if (defaultOrderByColumn) {+ // queryChains = queryChains.order(table.name, defaultOrderByColumn, true, true)+ // }+ // } else {+ sorts.forEach((x) => {+ queryChains = queryChains.order(x.table, x.column, x.ascending, x.nullsFirst)+ })+ // }// getPagination is expecting to start from 0const { from, to } = getPagination((page ?? 1) - 1, limit)