Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. I am always amazed by the expert mode of the SQLite CLI.

I am always amazed by the expert mode of the SQLite CLI.

Scheduled Pinned Locked Moved Uncategorized
sqlite
15 Posts 7 Posters 24 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • bohwaz@mamot.frB bohwaz@mamot.fr

    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

    larsmb@mastodon.onlineL This user is from outside of this forum
    larsmb@mastodon.onlineL This user is from outside of this forum
    larsmb@mastodon.online
    wrote last edited by
    #6

    @bohwaz Oh, I didn't know that. I did know about postgres's EXPLAIN, but that's somewhat less helpful.

    1 Reply Last reply
    0
    • bohwaz@mamot.frB bohwaz@mamot.fr

      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

      delsehi@mastodon.nuD This user is from outside of this forum
      delsehi@mastodon.nuD This user is from outside of this forum
      delsehi@mastodon.nu
      wrote last edited by
      #7

      @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@mamot.frB 1 Reply Last reply
      0
      • delsehi@mastodon.nuD delsehi@mastodon.nu

        @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@mamot.frB This user is from outside of this forum
        bohwaz@mamot.frB This user is from outside of this forum
        bohwaz@mamot.fr
        wrote last edited by
        #8

        @delsehi
        Interesting. I never used SQL server though. But I don't think this exists in MySQL, postgre or Oracle.

        1 Reply Last reply
        0
        • bohwaz@mamot.frB bohwaz@mamot.fr

          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

          craigfrancis@mastodon.socialC This user is from outside of this forum
          craigfrancis@mastodon.socialC This user is from outside of this forum
          craigfrancis@mastodon.social
          wrote last edited by
          #9

          @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):

          Link Preview Image
          fw_error_www

          favicon

          (dev.mysql.com)

          bohwaz@mamot.frB 1 Reply Last reply
          0
          • craigfrancis@mastodon.socialC craigfrancis@mastodon.social

            @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):

            Link Preview Image
            fw_error_www

            favicon

            (dev.mysql.com)

            bohwaz@mamot.frB This user is from outside of this forum
            bohwaz@mamot.frB This user is from outside of this forum
            bohwaz@mamot.fr
            wrote last edited by
            #10

            @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@mastodon.socialC 1 Reply Last reply
            0
            • bohwaz@mamot.frB bohwaz@mamot.fr

              @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@mastodon.socialC This user is from outside of this forum
              craigfrancis@mastodon.socialC This user is from outside of this forum
              craigfrancis@mastodon.social
              wrote last edited by
              #11

              @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@mamot.frB 1 Reply Last reply
              0
              • craigfrancis@mastodon.socialC craigfrancis@mastodon.social

                @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@mamot.frB This user is from outside of this forum
                bohwaz@mamot.frB This user is from outside of this forum
                bohwaz@mamot.fr
                wrote last edited by
                #12

                @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@mastodon.socialC 1 Reply Last reply
                0
                • bohwaz@mamot.frB bohwaz@mamot.fr

                  @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@mastodon.socialC This user is from outside of this forum
                  craigfrancis@mastodon.socialC This user is from outside of this forum
                  craigfrancis@mastodon.social
                  wrote last edited by
                  #13

                  @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 🙂

                  1 Reply Last reply
                  0
                  • bohwaz@mamot.frB bohwaz@mamot.fr

                    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

                    mdfranz@infosec.exchangeM This user is from outside of this forum
                    mdfranz@infosec.exchangeM This user is from outside of this forum
                    mdfranz@infosec.exchange
                    wrote last edited by
                    #14

                    @bohwaz now I'm going to have to check ClickHouse and DuckDb. 🤔

                    1 Reply Last reply
                    0
                    • bohwaz@mamot.frB bohwaz@mamot.fr

                      @TimWardCam
                      Nope explain doesn't tell you which index you should create. It just tells you what the query planner does.

                      theconstructor@social.tchncs.deT This user is from outside of this forum
                      theconstructor@social.tchncs.deT This user is from outside of this forum
                      theconstructor@social.tchncs.de
                      wrote last edited by
                      #15

                      @bohwaz @TimWardCam in SQL Server query plan gives you the CREATE INDEX SQL, if it thinks it's badly needed

                      1 Reply Last reply
                      0
                      • R relay@relay.an.exchange shared this topic
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups