@query-doctor/core 0.4.2-rc.1 → 0.5.0-beta.1
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 +26 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +26 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1781,6 +1781,9 @@ var Statistics = class Statistics {
|
|
|
1781
1781
|
});
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
+
const sample = columnStatsValues.find((v) => v.table_name === "users" && v.stakind3 !== 0);
|
|
1785
|
+
if (sample) console.log("[stats debug] sample stakind3:", sample.stakind3, "stanumbers3:", sample.stanumbers3);
|
|
1786
|
+
else console.log("[stats debug] no users column found with non-zero stakind3");
|
|
1784
1787
|
/**
|
|
1785
1788
|
* Postgres has 5 different slots for storing statistics per column and a potentially unlimited
|
|
1786
1789
|
* number of statistic types to choose from. Each code in `stakindN` can mean different things.
|
|
@@ -1989,7 +1992,9 @@ var Statistics = class Statistics {
|
|
|
1989
1992
|
returning starelid, staattnum, stainherit, stakind1, stakind2, stakind3, stakind4, stakind5
|
|
1990
1993
|
)
|
|
1991
1994
|
select * from updated union all (select * from inserted); -- @qd_introspection`;
|
|
1992
|
-
columnStatsUpdatePromise = tx.exec(sql, [columnStatsValues]).
|
|
1995
|
+
columnStatsUpdatePromise = tx.exec(sql, [columnStatsValues]).then((rows) => {
|
|
1996
|
+
console.log("[stats debug] restore result rows:", JSON.stringify(rows));
|
|
1997
|
+
}).catch((err) => {
|
|
1993
1998
|
console.error("Something wrong wrong updating column stats");
|
|
1994
1999
|
console.error(err);
|
|
1995
2000
|
throw err;
|
|
@@ -2084,24 +2089,27 @@ var Statistics = class Statistics {
|
|
|
2084
2089
|
'columnName', c.column_name,
|
|
2085
2090
|
'stats', (
|
|
2086
2091
|
SELECT json_build_object(
|
|
2087
|
-
'starelid',
|
|
2088
|
-
'staattnum',
|
|
2089
|
-
'stanullfrac',
|
|
2090
|
-
'stawidth',
|
|
2091
|
-
'stadistinct',
|
|
2092
|
-
'stakind1',
|
|
2093
|
-
'stakind2',
|
|
2094
|
-
'stakind3',
|
|
2095
|
-
'stakind4',
|
|
2096
|
-
|
|
2097
|
-
'
|
|
2098
|
-
'
|
|
2099
|
-
'
|
|
2100
|
-
'
|
|
2101
|
-
'
|
|
2092
|
+
'starelid', cl.oid,
|
|
2093
|
+
'staattnum', a.attnum,
|
|
2094
|
+
'stanullfrac', ps.null_frac,
|
|
2095
|
+
'stawidth', ps.avg_width,
|
|
2096
|
+
'stadistinct', ps.n_distinct,
|
|
2097
|
+
'stakind1', CASE WHEN ps.most_common_vals IS NOT NULL THEN 1 ELSE 0 END, 'staop1', 0, 'stacoll1', 0, 'stanumbers1', ps.most_common_freqs,
|
|
2098
|
+
'stakind2', CASE WHEN ps.histogram_bounds IS NOT NULL THEN 2 ELSE 0 END, 'staop2', 0, 'stacoll2', 0, 'stanumbers2', NULL,
|
|
2099
|
+
'stakind3', CASE WHEN ps.correlation IS NOT NULL THEN 3 ELSE 0 END, 'staop3', 0, 'stacoll3', 0, 'stanumbers3', CASE WHEN ps.correlation IS NOT NULL THEN ARRAY[ps.correlation]::float4[] ELSE NULL END,
|
|
2100
|
+
'stakind4', CASE WHEN ps.most_common_elems IS NOT NULL THEN 4 ELSE 0 END, 'staop4', 0, 'stacoll4', 0,
|
|
2101
|
+
'stanumbers4', ps.most_common_elem_freqs,
|
|
2102
|
+
'stakind5', 0, 'staop5', 0, 'stacoll5', 0, 'stanumbers5', NULL,
|
|
2103
|
+
'stavalues1', CASE WHEN $1 THEN ps.most_common_vals ELSE NULL END,
|
|
2104
|
+
'stavalues2', CASE WHEN $1 THEN ps.histogram_bounds ELSE NULL END,
|
|
2105
|
+
'stavalues3', NULL,
|
|
2106
|
+
'stavalues4', CASE WHEN $1 THEN ps.most_common_elems ELSE NULL END,
|
|
2107
|
+
'stavalues5', NULL
|
|
2102
2108
|
)
|
|
2103
|
-
FROM
|
|
2104
|
-
WHERE
|
|
2109
|
+
FROM pg_stats ps
|
|
2110
|
+
WHERE ps.schemaname = c.table_schema
|
|
2111
|
+
AND ps.tablename = c.table_name
|
|
2112
|
+
AND ps.attname = c.column_name
|
|
2105
2113
|
)
|
|
2106
2114
|
)
|
|
2107
2115
|
ORDER BY c.ordinal_position
|