PostgreSQL index creation

Hello, I attempted to create the indexes adapting the commands to Postgresql and I had success for almost all of them.

-- xwikilargestrings  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwl_value ON xwikilargestrings (xwl_value);  

-- xwikidoc  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwd_parent ON xwikidoc (xwd_parent);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwd_class_xml ON xwikidoc (xwd_class_xml);  

-- xwikistatsdoc  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xws_number ON xwikistatsdoc (xws_number);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xws_classname ON xwikistatsdoc (xws_classname);  

-- xwikistatsreferer  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwr_number ON xwikistatsreferer (xwr_number);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwr_classname ON xwikistatsreferer (xwr_classname);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwr_referer ON xwikistatsreferer (xwr_referer);  

-- xwikistatsvisit  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwv_user_agent ON xwikistatsvisit (xwv_user_agent);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwv_cookie ON xwikistatsvisit (xwv_cookie);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwv_classname ON xwikistatsvisit (xwv_classname);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwv_number ON xwikistatsvisit (xwv_number);  

-- activitystream_events  
CREATE INDEX CONCURRENTLY IF NOT EXISTS ase_page_date ON activitystream_events (ase_page, ase_date);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS ase_param1 ON activitystream_events (ase_param1);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS ase_param2 ON activitystream_events (ase_param2);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS ase_param3 ON activitystream_events (ase_param3);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS ase_param4 ON activitystream_events (ase_param4);  
CREATE INDEX CONCURRENTLY IF NOT EXISTS ase_param5 ON activitystream_events (ase_param5);  

-- xwikiattrecyclebin  
CREATE INDEX CONCURRENTLY IF NOT EXISTS xda_docid1 ON xwikiattrecyclebin (xda_docid);  

My issue right now is with the first one:
CREATE INDEX CONCURRENTLY IF NOT EXISTS xwl_value ON xwikilargestrings (xwl_value);

It is returning the following error:

ERROR:  index row requires 20944 bytes, maximum size is 8191 

SQL state: 54000

Is there an alternative way or something to workaround this limitation?
I don’t want to make a mess lol.

Thank you :slight_smile:

hmm indeed it’s weird that we don’t have a page for postgresql at https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/Database%20Administration/#HIndexes

I thought we didn’t have one because it was not needed for postgresql as all indexes could be created automatically for it. But apparently I’m wrong since I can see entries missing “index” attributes on xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/xwiki.postgresql.hbm.xml at 93e5825fa7cd91abdbd1b4a65d7672e137299c5b · xwiki/xwiki-platform · GitHub

For example: xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/xwiki.postgresql.hbm.xml at 93e5825fa7cd91abdbd1b4a65d7672e137299c5b · xwiki/xwiki-platform · GitHub

There’s also no mention of indexes on https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationWAR/InstallationPostgreSQL/

@tmortagne any idea why we’re missing this? do you remember anything related to this?

Maybe our instructions were generic and also for postgresql and then I added DB-specific pages in https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/Database%20Administration/?viewer=changes&rev1=29.1&rev2=40.1&

And that lost the changes required for postgresql.

So for postgresql the following should work too normally (to be tested, maybe it used to work and doesn’t any more too): https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationWAR/InstallationMySQL/#HIndexes

1 Like

Hi Vincent, thank you for the answer, I ended up doing a partial indexing and the commands I used above are the ones that worked for me.

Bests,