XWiki uses by default a database to store its data. You will find on this page tips and tricks to administer and tune your database setup. For Installation please check the Installation guide which contains information on how to setup XWiki for multiple databases.

Indexes

To improve the performance of your XWiki instance when running with many documents you should run the following script to create indexes for your database (this has been tested for MySQL 5.0).

Indexes for XWiki versions after 4.3

Even though we've configured XWiki to let Hibernate create indexes by default, there are some limitations and some indexes cannot be created automatically for string columns longer than 255 chars (MySQL has a limit of 255 characters - See also InnoDB limits). Thus, at the moment the indexes listed below need to be created manually (for all databases since our default Hibernate configuration file doesn't specify creating indexes for those).
create index xwl_value on xwikilargestrings (xwl_value(50));
create index xwd_parent on xwikidoc (xwd_parent(50));
create index xwd_class_xml on xwikidoc (xwd_class_xml(20));
create index xws_number on xwikistatsdoc (XWS_NUMBER);
create index xws_classname on xwikistatsdoc (XWS_CLASSNAME);
create index xwr_number on xwikistatsreferer (XWR_NUMBER);
create index xwr_classname on xwikistatsreferer (XWR_CLASSNAME);
create index xwr_referer on xwikistatsreferer (XWR_REFERER(50));
create index xwv_user_agent on xwikistatsvisit (XWV_USER_AGENT(255));
create index xwv_cookie on xwikistatsvisit (XWV_COOKIE(255));
create index xwv_classname on xwikistatsvisit (XWV_CLASSNAME);
create index xwv_number on xwikistatsvisit (XWV_NUMBER);
create index ase_page_date on  activitystream_events (ase_page, ase_date);
create index xda_docid1 on xwikiattrecyclebin (xda_docid);
create index ase_param1 on activitystream_events (ase_param1(200));
create index ase_param2 on activitystream_events (ase_param2(200));
create index ase_param3 on activitystream_events (ase_param3(200));
create index ase_param4 on activitystream_events (ase_param4(200));
create index ase_param5 on activitystream_events (ase_param5(200));

Note to XWiki developers: The following indexes could be created automatically though since they're less than 255 characters and thus should be added in a future version of XWiki so that they don't need to be created manually:

create index xws_number on xwikistatsdoc (XWS_NUMBER);
create index xws_classname on xwikistatsdoc (XWS_CLASSNAME);
create index xwr_number on xwikistatsreferer (XWR_NUMBER);
create index xwr_classname on xwikistatsreferer (XWR_CLASSNAME);
create index xwv_classname on xwikistatsvisit (XWV_CLASSNAME);
create index xwv_number on xwikistatsvisit (XWV_NUMBER);
create index xda_docid1 on xwikiattrecyclebin (xda_docid);

Indexes for XWiki versions after 3.2

create index xwl_value on xwikilargestrings (xwl_value(50));
create index xwd_parent on xwikidoc (xwd_parent(50));
create index xwd_class_xml on xwikidoc (xwd_class_xml(20));
create index xws_number on xwikistatsdoc (XWS_NUMBER);
create index xws_classname on xwikistatsdoc (XWS_CLASSNAME);
create index xwr_number on xwikistatsreferer (XWR_NUMBER);
create index xwr_classname on xwikistatsreferer (XWR_CLASSNAME);
create index xwr_referer on xwikistatsreferer (XWR_REFERER(50));
create index xwv_user_agent on xwikistatsvisit (XWV_USER_AGENT(255));
create index xwv_cookie on xwikistatsvisit (XWV_COOKIE(255));
create index xwv_classname on xwikistatsvisit (XWV_CLASSNAME);
create index xwv_number on xwikistatsvisit (XWV_NUMBER);
create index ase_requestid on  activitystream_events (ase_requestid(200));
create index ase_page_date on  activitystream_events (ase_page, ase_date);
create index xda_docid1 on xwikiattrecyclebin (xda_docid);
create index ase_param1 on activitystream_events (ase_param1(200));
create index ase_param2 on activitystream_events (ase_param2(200));
create index ase_param3 on activitystream_events (ase_param3(200));
create index ase_param4 on activitystream_events (ase_param4(200));
create index ase_param5 on activitystream_events (ase_param5(200));
  • Most indexes are created automatically starting with XWiki 3.2 and only the indexes listed above need to be created. 
  • For older versions every index must be created manually. You can see the full list of indexes that should be created for older versions below. There is now an application that runs this script automatically on XE and XEM directly from your wiki.

Indexes for XWiki versions before 3.2

create index DOC_SPACE on xwikidoc (XWD_WEB);
create index DOC_NAME on xwikidoc (XWD_NAME);
create index DOC_FULLNAME on xwikidoc (XWD_FULLNAME);
create index DOC_TITLE on xwikidoc (XWD_TITLE);
create index DOC_PARENT on xwikidoc (XWD_PARENT(50));
create index DOC_CREATION_DATE on xwikidoc (XWD_CREATION_DATE);
create index DOC_DATE on xwikidoc (XWD_DATE);
create index DOC_CONTENT_UPDATE_DATE on xwikidoc (XWD_CONTENT_UPDATE_DATE);
create index DOC_CREATOR on xwikidoc (XWD_CREATOR);
create index DOC_AUTHOR on xwikidoc (XWD_AUTHOR);
create index DOC_CONTENT_AUTHOR on xwikidoc (XWD_CONTENT_AUTHOR);
create index DOC_LANGUAGE on xwikidoc (XWD_LANGUAGE);
create index DOC_DEFAULT_LANGUAGE on xwikidoc (XWD_DEFAULT_LANGUAGE);
create index DOC_CLASS_XML on xwikidoc (XWD_CLASS_XML(20));
create index DOC_MINOREDIT on xwikidoc (XWD_MINOREDIT);
create index DOC_HIDDEN on xwikidoc (XWD_HIDDEN);
create index OBJ_NAME on xwikiobjects (XWO_NAME);
create index OBJ_CLASSNAME on xwikiobjects (XWO_CLASSNAME);
create index OBJ_NUMBER on xwikiobjects (XWO_NUMBER);

create index XWINT_NAME on xwikiintegers (XWI_NAME);
create index XWINT_VALUE on xwikiintegers (XWI_VALUE);
create index XWLONG_NAME on xwikilongs (XWL_NAME);
create index XWLONG_VALUE on xwikilongs (XWL_VALUE);
create index XWFLOAT_NAME on xwikifloats (XWF_NAME);
create index XWFLOAT_VALUE on xwikifloats (XWF_VALUE);
create index XWDOUBLE_NAME on xwikidoubles (XWD_NAME);
create index XWDOUBLE_VALUE on xwikidoubles (XWD_VALUE);
create index XWDATE_NAME on xwikidates (XWS_NAME);
create index XWDATE_VALUE on xwikidates (XWS_VALUE);
create index XWSTR_NAME on xwikistrings (XWS_NAME);
create index XWSTR_VALUE on xwikistrings (XWS_VALUE);
create index XWLS_NAME on xwikilargestrings (XWL_NAME);
create index XWLS_VALUE on xwikilargestrings (XWL_VALUE(50));

create index xwr_isdiff on xwikircs(xwr_isdiff);
create index xws_name on xwikistatsdoc (XWS_NAME);
create index xws_number on xwikistatsdoc (XWS_NUMBER);
create index xws_classname on xwikistatsdoc (XWS_CLASSNAME);
create index xws_action on xwikistatsdoc (XWS_ACTION);
create index xws_page_views on xwikistatsdoc (XWS_PAGE_VIEWS);
create index xws_unique_visitors on xwikistatsdoc (XWS_UNIQUE_VISITORS);
create index xws_period on xwikistatsdoc (XWS_PERIOD);
create index xws_visits on xwikistatsdoc (XWS_VISITS);
create index xwr_number on xwikistatsreferer (XWR_NUMBER);
create index xwr_name on xwikistatsreferer (XWR_NAME);
create index xwr_classname on xwikistatsreferer (XWR_CLASSNAME);
create index xwr_referer on xwikistatsreferer (XWR_REFERER(50));
create index xwr_page_views on xwikistatsreferer (XWR_PAGE_VIEWS);
create index xwr_period on xwikistatsreferer (XWR_PERIOD);
create index xwv_start_date on xwikistatsvisit (XWV_START_DATE);
create index xwv_name on xwikistatsvisit (XWV_NAME);
create index xwv_page_views on xwikistatsvisit (XWV_PAGE_VIEWS);
create index xwv_page_saves on xwikistatsvisit (XWV_PAGE_SAVES);
create index xwv_downloads on xwikistatsvisit (XWV_DOWNLOADS);
create index xwv_end_date on xwikistatsvisit (XWV_END_DATE);
create index xwv_ip on xwikistatsvisit (XWV_IP);
create index xwv_user_agent on xwikistatsvisit (XWV_USER_AGENT(255));
create index xwv_cookie on xwikistatsvisit (XWV_COOKIE(255));
create index xwv_unique_id on xwikistatsvisit (XWV_UNIQUE_ID);
create index xwv_classname on xwikistatsvisit (XWV_CLASSNAME);
create index xwv_number on xwikistatsvisit (XWV_NUMBER);

create index xdd_fullname1 on xwikirecyclebin (xdd_fullname);
create index xdd_language on xwikirecyclebin (xdd_language);
create index xdd_date on xwikirecyclebin (xdd_date);
create index xdd_deleter on xwikirecyclebin (xdd_deleter);
create index xda_docid1 on xwikiattrecyclebin (xda_docid);
create index xda_doc_name on xwikiattrecyclebin (xda_doc_name);
create index xda_filename on xwikiattrecyclebin (xda_filename);
create index xda_date on xwikiattrecyclebin (xda_date);
create index xda_deleter on xwikiattrecyclebin (xda_deleter);

create index ase_requestid on  activitystream_events (ase_requestid(200));
create index ase_stream on  activitystream_events (ase_stream);
create index ase_date on  activitystream_events (ase_date);
create index ase_type on  activitystream_events (ase_type);
create index ase_application on  activitystream_events (ase_application);
create index ase_user on  activitystream_events (ase_user);
create index ase_wiki on  activitystream_events (ase_wiki);
create index ase_space on  activitystream_events (ase_space);
create index ase_page on  activitystream_events (ase_page);
create index ase_page_date on  activitystream_events (ase_page, ase_date);

Sanity Checks

To verify the consistency of your XWiki database you can run the sanity check script. The script will select rows that are inconsistent with the logics of XWiki. If no rows are selected, it means the script itself can not detect any error.

  • If you use MySQL as your database:
    • The following sanity check script has been tested for MySQL 5.0 (also been reported to work with MS-SQL)
    • Another script is a variant of the previous script for MySQL 4.x replacing some syntax with more ancient one (still reports errors in one command)
  • If you use postgresql as your database:
    • Here is a modified version of the sanity check script, to be run in the "query" tool of pgAdmin. It is the same as the script for MySQL, except that the syntax for SQL comments is different.
    • pgAdmin is the GUI tool provided with postgresql to access the database. Run pgAdmin, select the xwiki database, and choose the "Query" option in the "Tools" menu. Then just open the script and click on the play icon ("Execute query").

Database browsing

DbVisualizer

DbVisualizer natively supports these DBs:

  • DB2 for Windows/Linux
  • JavaDB/Derby
  • MySQL
  • PostgreSQL
  • and more

Any DB using the corresponding JDBC driver:

  • Example: HSQLDB by using the driver bundled with XWiki
Tags:
Created by Vincent Massol on 2017/09/06
   

Get Connected