Find a file
Dan Stillman e532e435f4 Fix very slow purging of itemDataValues at startup in large databases
When an item is erased (removed from the trash or cleaned up from a
feed), we set a flag to purge values in `itemDataValues` on the next
startup, with this query:

DELETE FROM itemDataValues WHERE valueID NOT IN (SELECT valueID FROM itemData);

For some people, that query was incredibly slow and would result in
Zotero intermittently hanging on "Loading items…" for a long time at
startup. It's possible this is mostly limited to people who subscribe to
high-volume feeds and have a lot of item churn. One affected person had
>900K values in `itemDataValues` despite having only 20K items.

It turns out the slow query is due to the foreign-key constraint on
`itemData(valueID)` that references`itemDataValues(valueID)`. SQLite is
checking every row being deleted from `itemDataValues` against
`itemData`, even though the query is specifically removing rows that
don't exist in `itemData`! For the 900K-value DB, disabling foreign-key
checks causes the `DELETE` query to take 25 seconds instead of...some
much longer time that I didn't wait for.

We already had an `executeTransaction()` flag, `disableForeignKeys`, to
temporarily disable foreign-key checks, but it didn't do so in a way
that was safe for post-initialization usage -- a write query outside of
a transaction could've run between the transaction commit and
foreign-key checks being re-enabled. This commit changes it to properly
block all other queries unless they include an `ignoreDBLock` option,
meaning that queries within the function passed to the transaction need
to include that option. (And since that's not realistic for the couple
other uses of `disableForeignKeys` -- one for a test and one in code
that almost certainly hasn't been run by anyone in 15 years -- those now
just run `PRAGMA foreign_keys=OFF|ON` explicitly, leaving this as the
only current use.)
2025-03-10 04:26:16 -04:00
.github/workflows Remove issue template 2025-02-10 23:25:03 -05:00
app build_and_run: Fix handling of ZOTERO_PROFILE containing spaces 2025-03-09 16:16:47 -04:00
chrome Fix very slow purging of itemDataValues at startup in large databases 2025-03-10 04:26:16 -04:00
defaults/preferences Sort strings naturally or alphabetically (#5075) 2025-03-07 02:08:11 -05:00
js-build Scaffold: Infer types of parameters based on naming conventions (#5038) 2025-02-18 05:07:51 -05:00
note-editor@ae92348364 Normalize decomposed chars in PDF text, Zotero notes for proper indexing 2025-02-21 14:55:20 +02:00
pdf-worker@0c1e6090ee Update pdf-worker submodule 2025-02-26 18:10:58 +02:00
reader@db3149ea27 Update reader submodule 2025-03-05 07:30:21 -05:00
resource Scaffold: Infer types of parameters based on naming conventions (#5038) 2025-02-18 05:07:51 -05:00
scripts fx128: Add arrowscrollbox.ftl from Mozilla 2025-01-08 01:41:29 -05:00
scss Advanced Search: Remove red background from condition tooltips 2025-02-26 16:41:07 -05:00
styles@1554b78c31 Update styles 2024-12-03 16:11:24 -05:00
test Add tests for renderItemTitle() 2025-03-06 11:00:33 -05:00
translators@4cadb3e145 Update translators 2024-11-26 02:34:02 -05:00
types/gecko Add Gecko types and a script to update them (#4296) 2024-07-02 00:58:51 -04:00
.babelrc Use production builds of react libraries (#4482) 2024-08-02 03:43:02 -04:00
.gitattributes Update Linux updater for Zotero 7 2023-05-20 10:51:47 +00:00
.gitignore Use user-provided codesign script for Windows signing 2024-04-08 10:12:58 +01:00
.gitmodules Remove chai-as-promised submodule 2025-03-05 22:59:49 -05:00
chrome.manifest fx115: working autocomplete (#3789) 2024-03-30 00:58:57 -04:00
CONTRIBUTING.md Add "support questions" to CONTRIBUTING.md 2022-12-01 05:10:42 -05:00
COPYING Update COPYING 2018-03-26 11:27:48 +02:00
eslint.config.mjs Add Cr as glboal in eslint config 2025-03-05 05:51:04 -05:00
package-lock.json Update ESLint and Babel 2025-01-09 03:11:01 -05:00
package.json Update ESLint and Babel 2025-01-09 03:11:01 -05:00
README.md "Zotero wiki" → "Zotero documentation" in app build README 2023-04-26 04:40:22 -04:00
update.rdf Update Fx minVersion to 45 2016-12-13 09:12:55 -05:00
version Update version to 7.1 2025-01-03 01:21:57 -05:00

Zotero

CI

Zotero is a free, easy-to-use tool to help you collect, organize, cite, and share your research sources.

Please post feature requests or bug reports to the Zotero Forums. If you're having trouble with Zotero, see Getting Help.

For more information on how to use this source code, see the Zotero documentation.