Add an index on the full_insee field
This DB is mostly used to retrieve all the street names for a given city. Adding an index for the full_insee field greatly improves the query time. Without the index: time $(echo 'select * from fantoir where full_insee="65054";' | sqlite3 fantoir.sqlite) real 0m2,230s user 0m1,896s sys 0m0,337s With the index: time $(echo 'select * from fantoir where full_insee=65054;' | sqlite3 fantoir.sqlite) real 0m0,148s user 0m0,126s sys 0m0,024s
This commit is contained in:
parent
3bd8aa86bc
commit
6787e782da
|
@ -17,14 +17,16 @@ trap clean_tmp EXIT
|
||||||
tmpCsv="${tmpDir}"/fantoir.csv
|
tmpCsv="${tmpDir}"/fantoir.csv
|
||||||
tmpSql="${tmpDir}"/import-fantoir.sql
|
tmpSql="${tmpDir}"/import-fantoir.sql
|
||||||
|
|
||||||
echo "Generating fantoir CSV"
|
echo "[+] Generating fantoir CSV"
|
||||||
cargo run --release -- "$1" > "${tmpCsv}"
|
cargo run --release -- "$1" > "${tmpCsv}"
|
||||||
|
|
||||||
echo "Generating fantoir SQLite DB"
|
echo "[+] Generating fantoir SQLite DB"
|
||||||
cat >"${tmpSql}" <<EOF
|
cat >"${tmpSql}" <<EOF
|
||||||
.separator ";"
|
.separator ";"
|
||||||
.import ${tmpCsv} fantoir
|
.import ${tmpCsv} fantoir
|
||||||
EOF
|
EOF
|
||||||
sqlite3 fantoir.sqlite < "${tmpSql}"
|
sqlite3 fantoir.sqlite < "${tmpSql}"
|
||||||
|
echo "[+] Populating DB index"
|
||||||
|
echo "CREATE INDEX insee_fantoir ON fantoir(full_insee);" | sqlite3 fantoir.sqlite
|
||||||
|
|
||||||
echo "DB generated at $(pwd)/fantoir.sqlite"
|
echo "[+] DB generated at $(pwd)/fantoir.sqlite"
|
||||||
|
|
Loading…
Reference in a new issue