@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.js
CHANGED
|
@@ -1172,7 +1172,31 @@ var _IndexOptimizer = class _IndexOptimizer {
|
|
|
1172
1172
|
// TODO: this doesn't belong in the optimizer
|
|
1173
1173
|
indexAlreadyExists(table, columns) {
|
|
1174
1174
|
return this.existingIndexes.find(
|
|
1175
|
-
(index) => index.index_type === "btree" && index.table_name === table && index.index_columns.length === columns.length && index.index_columns.every((c, i) =>
|
|
1175
|
+
(index) => index.index_type === "btree" && index.table_name === table && index.index_columns.length === columns.length && index.index_columns.every((c, i) => {
|
|
1176
|
+
if (columns[i].column !== c.name) {
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
if (columns[i].where) {
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
if (columns[i].sort) {
|
|
1183
|
+
switch (columns[i].sort.dir) {
|
|
1184
|
+
// Sorting is ASC by default in postgres
|
|
1185
|
+
case "SORTBY_DEFAULT":
|
|
1186
|
+
case "SORTBY_ASC":
|
|
1187
|
+
if (c.order !== "ASC") {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
break;
|
|
1191
|
+
case "SORTBY_DESC":
|
|
1192
|
+
if (c.order !== "DESC") {
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1195
|
+
break;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
return true;
|
|
1199
|
+
})
|
|
1176
1200
|
);
|
|
1177
1201
|
}
|
|
1178
1202
|
/**
|
|
@@ -1372,7 +1396,7 @@ var _IndexOptimizer = class _IndexOptimizer {
|
|
|
1372
1396
|
replaceUsedIndexesWithDefinition(explain, triedIndexes) {
|
|
1373
1397
|
walkExplain(explain, (stage) => {
|
|
1374
1398
|
const indexName = stage["Index Name"];
|
|
1375
|
-
if (indexName) {
|
|
1399
|
+
if (typeof indexName === "string") {
|
|
1376
1400
|
const recommendation = triedIndexes.get(indexName);
|
|
1377
1401
|
if (recommendation) {
|
|
1378
1402
|
stage["Index Name"] = recommendation.definition;
|
|
@@ -1392,6 +1416,7 @@ function walkExplain(explain, f) {
|
|
|
1392
1416
|
}
|
|
1393
1417
|
}
|
|
1394
1418
|
}
|
|
1419
|
+
go(explain);
|
|
1395
1420
|
}
|
|
1396
1421
|
var RollbackError = class {
|
|
1397
1422
|
constructor(value) {
|