Skip to content

[6.x] Stop re-checking index existence on every Algolia write - #15090

Open
edalzell wants to merge 1 commit into
statamic:6.xfrom
edalzell:fix/algolia-redundant-list-indices
Open

[6.x] Stop re-checking index existence on every Algolia write#15090
edalzell wants to merge 1 commit into
statamic:6.xfrom
edalzell:fix/algolia-redundant-list-indices

Conversation

@edalzell

Copy link
Copy Markdown
Contributor

Was debugging a search index update timeout issue and when profiling discovered that settingsInitialized was only set inside the branch that runs when the index does not exist. Once an index had been created, the flag stayed false forever, so every call to client() re-ran exists() and spent an extra listIndices() API call before each write.

On a 2,773 document reindex (chunk size 10, 278 jobs) this meant 280 listIndices() calls costing ~24.5s, roughly half of all the time the reindex spent talking to Algolia.

Set the flag regardless of whether the index already existed, so the check happens at most once per index instance.

`settingsInitialized` was only set inside the branch that runs when the
index does not exist. Once an index had been created, the flag stayed
false forever, so every call to client() re-ran exists() and spent an
extra listIndices() API call before each write.

On a 2,773 document reindex (chunk size 10, 278 jobs) this meant 280
listIndices() calls costing ~24.5s, roughly half of all the time the
reindex spent talking to Algolia.

Set the flag regardless of whether the index already existed, so the
check happens at most once per index instance.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@edalzell edalzell changed the title Stop re-checking index existence on every Algolia write [6.x] Stop re-checking index existence on every Algolia write Jul 29, 2026
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

Successfully merging this pull request may close these issues.

1 participant