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

Deleted records stay in the search index #18

Open
simonw opened this issue Sep 8, 2020 · 2 comments
Open

Deleted records stay in the search index #18

simonw opened this issue Sep 8, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@simonw
Copy link
Collaborator

simonw commented Sep 8, 2020

Here's why:

sql_rest = sql.split("select", 1)[1]
sql = "select '{}/{}' as [table],{}".format(db_name, table, sql_rest)
columns = derive_columns(other_db, sql)
with other_db.conn:
other_db.conn.execute(
"REPLACE INTO index1.search_index ({}) {}".format(
", ".join("[{}]".format(column) for column in columns), sql
)
)
other_db.conn.close()

That should probably do DELETE FROM index1.search_index WHERE [table] = ? first.

@simonw simonw added the bug Something isn't working label Sep 8, 2020
@simonw
Copy link
Collaborator Author

simonw commented Sep 8, 2020

Alternatively it could run as it does now but add a DELETE FROM index1.search_index WHERE key not in (select key from ...).

I'm not sure which would be more efficient.

@simonw
Copy link
Collaborator Author

simonw commented Sep 8, 2020

I'm inclined to go with the first, simpler option. I have longer term plans for efficient incremental index updates based on clever trickery with triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant