I am always amazed by the expert mode of the SQLite CLI.
-
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert@bohwaz Plenty have an "explain" feature which gives you the same information albeit less directly.
-
@bohwaz Plenty have an "explain" feature which gives you the same information albeit less directly.
@TimWardCam
Nope explain doesn't tell you which index you should create. It just tells you what the query planner does. -
@TimWardCam
Nope explain doesn't tell you which index you should create. It just tells you what the query planner does.@bohwaz It's often enough blindingly obvious what you should do about it - I did say "less directly".
-
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert@bohwaz Oh, I didn't know that. I did know about postgres's EXPLAIN, but that's somewhat less helpful.
-
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert@bohwaz I'm slightly confident that SQL Server has something like this too, but you get those recommendations by querying the proprietary version of INFORMATION_SCHEMA (or use the GUI in the Azure Portal). It's also based on how often some columns are used in queries, so it also uses some internal telemetry
-
@bohwaz I'm slightly confident that SQL Server has something like this too, but you get those recommendations by querying the proprietary version of INFORMATION_SCHEMA (or use the GUI in the Azure Portal). It's also based on how often some columns are used in queries, so it also uses some internal telemetry
@delsehi
Interesting. I never used SQL server though. But I don't think this exists in MySQL, postgre or Oracle. -
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert@bohwaz tbh I’ve not used this, but MySQL does have the System Variable `log_queries_not_using_indexes`, which I assume would push you towards using an INDEX on all queries (but the docs suggest to me it’s more about queries that return all rows):
-
@bohwaz tbh I’ve not used this, but MySQL does have the System Variable `log_queries_not_using_indexes`, which I assume would push you towards using an INDEX on all queries (but the docs suggest to me it’s more about queries that return all rows):
@craigfrancis
Yup but it will not tell you which indexes should be created, you'll have to think about the query and try things yourself. Fine for a simple query, but when it's a 100 lines long... Slightly harder :) -
@craigfrancis
Yup but it will not tell you which indexes should be created, you'll have to think about the query and try things yourself. Fine for a simple query, but when it's a 100 lines long... Slightly harder :)@bohwaz true, and I think SQLite has some really cool features like that… personally I’m trying get MySQL and MariaDB to implement a very simple `WHERE id IN (?)` with a single placeholder for multiple values, as I still keep seeing people `implode(‘, ‘, $ids)` directly into the SQL string for some of that SQL Injection fun :-)
-
@bohwaz true, and I think SQLite has some really cool features like that… personally I’m trying get MySQL and MariaDB to implement a very simple `WHERE id IN (?)` with a single placeholder for multiple values, as I still keep seeing people `implode(‘, ‘, $ids)` directly into the SQL string for some of that SQL Injection fun :-)
@craigfrancis
I'm personally using a custom ?? placeholder for this case. And I use implode, but before the call I'm quoting each value :) -
@craigfrancis
I'm personally using a custom ?? placeholder for this case. And I use implode, but before the call I'm quoting each value :)@bohwaz yep, that’s probably fine, but I’m not worried about you, I’m worried about the vast majority of developers, and those who aren’t exactly writing the code themselves :-)
-
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert@bohwaz now I'm going to have to check ClickHouse and DuckDb. 🤔
-
@TimWardCam
Nope explain doesn't tell you which index you should create. It just tells you what the query planner does.@bohwaz @TimWardCam in SQL Server query plan gives you the CREATE INDEX SQL, if it thinks it's badly needed
-
undefined oblomov@sociale.network shared this topic on
-
How it works is also clever: it analyses the where and order by clauses of the query, creates indexes based on that, retries the query and checks which indexes have been used. Simple but effective!
@bohwaz this takes me back 20 years to using EXPLAIN SELECT in MySQL and the like 😺 (although having to then determine and add the indexes based on its output myself)
-
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert -
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expertAh nice, a clever piece of code. A pattern that will be collected by the AI borg, transmogrified and assimilated into an AI codebase in the future. -
@barnibu
Interesting. Then I can correct my statement: the only open source database to have this :) -
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert -
I am always amazed by the expert mode of the SQLite CLI.
You type .expert
Then you paste your SQL query.
And #sqlite tells you which indexes you should create to speed up your query.No AI, no complex program to install. No expensive database architect to pay for. It's just clever programming.
To my knowledge this is the only database in the world to have this feature.
https://sqlite.org/cli.html#index_recommendations_sqlite_expert_
https://sqlite.org/src/dir?ci=trunk&name=ext/expert@bohwaz thank you for tipping me off to this fantastic feature 👌 another reason to love sqlite
-
undefined aeva@mastodon.gamedev.place shared this topic