Projects tigase _server server-core Issues #1365
Flatten UserData (tig_nodes / tig_pairs) schema to avoide performance issues (JDBCRepository NID subquery doesn't use index making the call slow) (#1365)
Open
wojciech.kapcia@tigase.net opened 11 months ago

While tree-like structure of UserData gives quite a lot of flexibility it's not utilised but entails performance issues without much benefit.


mysql> explain select nid as nid2, node as node2 from tig_nodes, (select nid as nid1 from tig_nodes where (uid = 18033992) AND (parent_nid is null) AND (node = 'root')) nodes1 where (parent_nid = nid1) AND (node = 'message-archive') \G

*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: tig_nodes
   partitions: NULL
         type: ref
possible_keys: PRIMARY,tnode,node,uid,parent_nid
          key: tnode
      key_len: 784
          ref: const,const,const
         rows: 1
     filtered: 100.00
        Extra: Using where; Using index
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: tig_nodes
   partitions: NULL
         type: ref
possible_keys: tnode,node,parent_nid
          key: node
      key_len: 767
          ref: const
         rows: 149706
     filtered: 100.00
        Extra: Using where
2 rows in set, 1 warning (0.00 sec)

Culprit: tigase.db.jdbc.JDBCRepository#buildNodeQuery


The bug is on the SQL query that make the join with the comma.

with a simple subquery all the index works correctly filtering olny 2 rows!

-> https://tigase.dev/helpdesk/helpdesk-priv/~issues/1167#IssueComment-96568


https://dev.mysql.com/doc/refman/8.0/en/subquery-optimization.html

wojciech.kapcia@tigase.net batch edited 4 months ago
Name Previous Value Current Value
Iterations
empty
tigase-server-8.4.0
wojciech.kapcia@tigase.net batch edited 3 months ago
Name Previous Value Current Value
Iterations
tigase-server-8.4.0
tigase-server-8.5.0
Version
tigase-server-8.4.0
tigase-server-8.5.0
wojciech.kapcia@tigase.net changed title 1 month ago
Previous Value Current Value
JDBCRepository NID subquery doesn't use index making the call slow
Flatten UserData (tig_nodes / tig_pairs) schema to avoide performance issues (JDBCRepository NID subquery doesn't use index making the call slow)
wojciech.kapcia@tigase.net added "Related" #1227 3 weeks ago
wojciech.kapcia@tigase.net added "Related" Customers/catapush-s-r-l#35 3 weeks ago
issue 1 of 1
Type
Performance
Priority
Normal
Assignee
Version
tigase-server-8.5.0
Iterations
Issue Votes (0)
Watchers (3)
Reference
tigase/_server/server-core#1365
Please wait...
Page is in error, reload to recover