Search notes:

SQLite: force using a specific index with INDEXED BY

SQLite allows to use the hint indexed by to force the query planner to use a specific index:
create table tq84_tab (
  id   number primary key,
  col  text
);

explain query plan
  select *
  from tq84_tab
  where
    id  =  42 and
    col = 'val';
--
-- 0|0|0|SEARCH TABLE tq84_tab USING INDEX sqlite_autoindex_tq84_tab_1 (id=?)
--

create index tq84_tab_ix_col on tq84_tab (col); 

explain query plan
  select *
  from tq84_tab
  where
    id  =  42 and
    col = 'val';
-- 
-- 0|0|0|SEARCH TABLE tq84_tab USING INDEX sqlite_autoindex_tq84_tab_1 (id=?)
-- 

explain query plan
  select *
  from tq84_tab INDEXED BY tq84_tab_ix_col
  where
    id  =  42 and
    col = 'val';
-- 
-- 0|0|0|SEARCH TABLE tq84_tab USING INDEX tq84_tab_ix_col (col=?)
-- 
Github repository about-sqlite, path: /indices/indexed-by.sql

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759421525, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQLite/indices/indexed-by(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78