Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
e79db0a6
Commit
e79db0a6
authored
7 years ago
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
switch back from GIST to GIN indexes
parent
3f9f1c50
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/search.py
+13
-8
13 additions, 8 deletions
synapse/storage/search.py
with
13 additions
and
8 deletions
synapse/storage/search.py
+
13
−
8
View file @
e79db0a6
...
@@ -31,7 +31,7 @@ class SearchStore(BackgroundUpdateStore):
...
@@ -31,7 +31,7 @@ class SearchStore(BackgroundUpdateStore):
EVENT_SEARCH_UPDATE_NAME
=
"
event_search
"
EVENT_SEARCH_UPDATE_NAME
=
"
event_search
"
EVENT_SEARCH_ORDER_UPDATE_NAME
=
"
event_search_order
"
EVENT_SEARCH_ORDER_UPDATE_NAME
=
"
event_search_order
"
EVENT_SEARCH_USE_GI
ST
_POSTGRES_NAME
=
"
event_search_postgres_gi
st
"
EVENT_SEARCH_USE_GI
N
_POSTGRES_NAME
=
"
event_search_postgres_gi
n
"
def
__init__
(
self
,
db_conn
,
hs
):
def
__init__
(
self
,
db_conn
,
hs
):
super
(
SearchStore
,
self
).
__init__
(
db_conn
,
hs
)
super
(
SearchStore
,
self
).
__init__
(
db_conn
,
hs
)
...
@@ -43,8 +43,8 @@ class SearchStore(BackgroundUpdateStore):
...
@@ -43,8 +43,8 @@ class SearchStore(BackgroundUpdateStore):
self
.
_background_reindex_search_order
self
.
_background_reindex_search_order
)
)
self
.
register_background_update_handler
(
self
.
register_background_update_handler
(
self
.
EVENT_SEARCH_USE_GI
ST
_POSTGRES_NAME
,
self
.
EVENT_SEARCH_USE_GI
N
_POSTGRES_NAME
,
self
.
_background_reindex_gi
st
_search
self
.
_background_reindex_gi
n
_search
)
)
@defer.inlineCallbacks
@defer.inlineCallbacks
...
@@ -145,25 +145,30 @@ class SearchStore(BackgroundUpdateStore):
...
@@ -145,25 +145,30 @@ class SearchStore(BackgroundUpdateStore):
defer
.
returnValue
(
result
)
defer
.
returnValue
(
result
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
_background_reindex_gist_search
(
self
,
progress
,
batch_size
):
def
_background_reindex_gin_search
(
self
,
progress
,
batch_size
):
'''
This handles old synapses which used GIST indexes; converting them
back to be GIN as per the actual schema. Otherwise it crashes out
as a NOOP
'''
def
create_index
(
conn
):
def
create_index
(
conn
):
conn
.
rollback
()
conn
.
rollback
()
conn
.
set_session
(
autocommit
=
True
)
conn
.
set_session
(
autocommit
=
True
)
c
=
conn
.
cursor
()
c
=
conn
.
cursor
()
c
.
execute
(
c
.
execute
(
"
CREATE INDEX CONCURRENTLY event_search_fts_idx
_gist
"
"
CREATE INDEX CONCURRENTLY event_search_fts_idx
"
"
ON event_search USING GI
ST
(vector)
"
"
ON event_search USING GI
N
(vector)
"
)
)
c
.
execute
(
"
DROP INDEX event_search_fts_idx
"
)
c
.
execute
(
"
DROP INDEX event_search_fts_idx
_gist
"
)
conn
.
set_session
(
autocommit
=
False
)
conn
.
set_session
(
autocommit
=
False
)
if
isinstance
(
self
.
database_engine
,
PostgresEngine
):
if
isinstance
(
self
.
database_engine
,
PostgresEngine
):
yield
self
.
runWithConnection
(
create_index
)
yield
self
.
runWithConnection
(
create_index
)
yield
self
.
_end_background_update
(
self
.
EVENT_SEARCH_USE_GI
ST
_POSTGRES_NAME
)
yield
self
.
_end_background_update
(
self
.
EVENT_SEARCH_USE_GI
N
_POSTGRES_NAME
)
defer
.
returnValue
(
1
)
defer
.
returnValue
(
1
)
@defer.inlineCallbacks
@defer.inlineCallbacks
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment