Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide FTS-created tables by default on the database index page #129

Closed
simonw opened this issue Nov 19, 2017 · 2 comments
Closed

Hide FTS-created tables by default on the database index page #129

simonw opened this issue Nov 19, 2017 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Nov 19, 2017

SQLite databases that use FTS include a number of automatically generated tables, e.g.:

https://sf-trees-search.now.sh/sf-trees-search-a899b92

sf-trees-search_and_sf-trees-search

Of these, only the Street_Tree_List table is actually relevant to the user.

We can detect which tables are FTS tables by first finding the virtual tables:

sqlite> .headers on
sqlite> select * from sqlite_master where rootpage = 0;
type|name|tbl_name|rootpage|sql
table|Search|Search|0|CREATE VIRTUAL TABLE "Street_Tree_List_fts" USING FTS4 ("qAddress", "qCaretaker", "qSpecies")

Then parsing the above to figure out which ones are USING FTS? - then assume that any table which starts with that Street_Tree_List_fts prefix was created to support search:

sqlite> select * from sqlite_master where type='table' and tbl_name like 'Street_Tree_List_fts%';
type|name|tbl_name|rootpage|sql
table|Search_content|Search_content|10355|CREATE TABLE 'Street_Tree_List_fts_content'(docid INTEGER PRIMARY KEY, 'c0qAddress', 'c1qCaretaker', 'c2qSpecies')
table|Search_segments|Search_segments|10356|CREATE TABLE 'Street_Tree_List_fts_segments'(blockid INTEGER PRIMARY KEY, block BLOB)
table|Search_segdir|Search_segdir|10357|CREATE TABLE 'Street_Tree_List_fts_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx))
table|Search_docsize|Search_docsize|10359|CREATE TABLE 'Street_Tree_List_fts_docsize'(docid INTEGER PRIMARY KEY, size BLOB)
table|Search_stat|Search_stat|10360|CREATE TABLE 'Street_Tree_List_fts_stat'(id INTEGER PRIMARY KEY, value BLOB)

We won't hide these completely - instead, we'll default the database index view to not showing them with a message that says "5 hidden tables" and support ?_hidden=1 to display them.

@simonw simonw added this to the SQLite extensions + advanced JSON edition milestone Nov 19, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 20, 2017

Need to hide these from the index summary page as well:

datasette__archive-fires-indonesia__conventional_power_plants_eu__fatal-police-shootings-data__fivethirtyeight__flights__google-trends__nhsadmin__northwind__openelections__polar-bears__sf-trees-fks__venue_profile

simonw added a commit that referenced this issue Nov 22, 2017
@simonw simonw closed this as completed in 1c8638c Nov 22, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 22, 2017

On the index page:

datasette__archive-fires-indonesia__conventional_power_plants_eu__fatal-police-shootings-data__fivethirtyeight__flights__google-trends__nhsadmin__northwind__openelections__polar-bears__sf-trees__sf-trees-fks__venue_profile_and_hide_fts-crea

On the database index page:

sf-trees

After clicking that link:

sf-trees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant