@query-doctor/core 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/optimizer/genalgo.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1222,7 +1222,31 @@ var _IndexOptimizer = class _IndexOptimizer {
|
|
|
1222
1222
|
// TODO: this doesn't belong in the optimizer
|
|
1223
1223
|
indexAlreadyExists(table, columns) {
|
|
1224
1224
|
return this.existingIndexes.find(
|
|
1225
|
-
(index) => index.index_type === "btree" && index.table_name === table && index.index_columns.length === columns.length && index.index_columns.every((c, i) =>
|
|
1225
|
+
(index) => index.index_type === "btree" && index.table_name === table && index.index_columns.length === columns.length && index.index_columns.every((c, i) => {
|
|
1226
|
+
if (columns[i].column !== c.name) {
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
if (columns[i].where) {
|
|
1230
|
+
return false;
|
|
1231
|
+
}
|
|
1232
|
+
if (columns[i].sort) {
|
|
1233
|
+
switch (columns[i].sort.dir) {
|
|
1234
|
+
// Sorting is ASC by default in postgres
|
|
1235
|
+
case "SORTBY_DEFAULT":
|
|
1236
|
+
case "SORTBY_ASC":
|
|
1237
|
+
if (c.order !== "ASC") {
|
|
1238
|
+
return false;
|
|
1239
|
+
}
|
|
1240
|
+
break;
|
|
1241
|
+
case "SORTBY_DESC":
|
|
1242
|
+
if (c.order !== "DESC") {
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return true;
|
|
1249
|
+
})
|
|
1226
1250
|
);
|
|
1227
1251
|
}
|
|
1228
1252
|
/**
|
|
@@ -1422,7 +1446,7 @@ var _IndexOptimizer = class _IndexOptimizer {
|
|
|
1422
1446
|
replaceUsedIndexesWithDefinition(explain, triedIndexes) {
|
|
1423
1447
|
walkExplain(explain, (stage) => {
|
|
1424
1448
|
const indexName = stage["Index Name"];
|
|
1425
|
-
if (indexName) {
|
|
1449
|
+
if (typeof indexName === "string") {
|
|
1426
1450
|
const recommendation = triedIndexes.get(indexName);
|
|
1427
1451
|
if (recommendation) {
|
|
1428
1452
|
stage["Index Name"] = recommendation.definition;
|
|
@@ -1442,6 +1466,7 @@ function walkExplain(explain, f) {
|
|
|
1442
1466
|
}
|
|
1443
1467
|
}
|
|
1444
1468
|
}
|
|
1469
|
+
go(explain);
|
|
1445
1470
|
}
|
|
1446
1471
|
var RollbackError = class {
|
|
1447
1472
|
constructor(value) {
|