-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs in analyze_empty_tables behavior
Signed-off-by: Aakash Arayambeth <aarayambeth@bloomberg.net>
- Loading branch information
Aakash Arayambeth
committed
Dec 5, 2024
1 parent
1b72251
commit 85641a2
Showing
5 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(count(*)=0) | ||
(count(*)=0) | ||
TURNING ON ANALYZE EMPTY TABLES | ||
(count(*)=1) | ||
(count(*)=1) | ||
INSERTING RECORDS | ||
(rows inserted=50000) | ||
RUNNING ANALYZE | ||
(count(*)=1) | ||
(count(*)=24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
function purge_stats | ||
{ | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "truncate sqlite_stat1" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "truncate sqlite_stat4" | ||
} | ||
function count_stats | ||
{ | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "select count(*) from sqlite_stat1" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "select count(*) from sqlite_stat4" | ||
} | ||
|
||
purge_stats | ||
#default behavior | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "DROP TABLE IF EXISTS empty" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "CREATE TABLE empty(a int primary key)" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "ANALYZE empty" | ||
count_stats | ||
|
||
echo "TURNING ON ANALYZE EMPTY TABLES" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "exec procedure sys.cmd.send('setsqlattr analyze_empty_tables on')" | ||
purge_stats | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "ANALYZE empty" | ||
count_stats | ||
|
||
echo "INSERTING RECORDS" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "INSERT INTO EMPTY SELECT * FROM generate_series(0,49999)" | ||
echo "RUNNING ANALYZE" | ||
purge_stats | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "ANALYZE empty" | ||
count_stats | ||
|
||
echo "TURNING OFF ANALYZE EMPTY TABLES" | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "exec procedure sys.cmd.send('setsqlattr analyze_empty_tables off')" | ||
echo "RUNNING ANALYZE" | ||
purge_stats | ||
${CDB2SQL_EXE} ${CDB2_OPTIONS} ${DBNAME} local "ANALYZE empty" | ||
count_stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
t16.sh |