@@ -109,14 +109,6 @@ class Node(Timestamped, Base):
109109 "access_blob" ,
110110 postgresql_using = "gin" ,
111111 ),
112- # PostgreSQL-specific covering index for fast key lookups.
113- Index (
114- "ix_nodes_parent_time_id_key" ,
115- "parent" ,
116- "time_created" ,
117- "id" ,
118- postgresql_include = ["key" ],
119- ),
120112 )
121113
122114
@@ -299,9 +291,9 @@ def unique_parameter_num_null_check(target, connection, **kw):
299291
300292@event .listens_for (Node .__table__ , "after_create" )
301293def create_index_metadata_tsvector_search (target , connection , ** kw ):
302- # This creates a ts_vector based metadata search index for fulltext.
303- # Postgres only feature
294+ # Postgres only features
304295 if connection .engine .dialect .name == "postgresql" :
296+ # This creates a ts_vector based metadata search index for fulltext
305297 connection .execute (
306298 text (
307299 """
@@ -311,6 +303,16 @@ def create_index_metadata_tsvector_search(target, connection, **kw):
311303 """
312304 )
313305 )
306+ # Covering B-tree index on (parent, time_created, id) INCLUDE (key)
307+ connection .execute (
308+ text (
309+ """
310+ CREATE INDEX ix_nodes_parent_time_id_key
311+ ON nodes (parent, time_created, id)
312+ INCLUDE (key)
313+ """
314+ )
315+ )
314316
315317
316318@event .listens_for (NodesClosure .__table__ , "after_create" )
0 commit comments