HiveSQL has several Full-Text Search (FTS) indexes, which speed up queries in an impressive way. They allow fast retrieval of information about comments and transfers
If you target one of the FTS indexed columns in your queries, use the CONTAINS or FREETEXT predicate functions rather than the infamous LIKE, which is a performance killer on tables with millions of records.
The following tables have been full-text search enabled:
There are 3 columns with Full-Text Search indexes:
Query example Let say I want to know if anyone mentioned the user "@arcange" in a post or comment, the following simple query will do the trick
SELECTauthor, title, body, urlFROMCommentsWHEREauthor <> 'arcange'CONTAINS(body, 'arcange')
Among all the columns found in the Comments table, one that is more and more used is the
It's the catch-all column, where developers can freely store any information about comments and their apps. As more and more information is stored by various projects into this column, then comes more and more queries trying to extract data from it.
Queries issued against this column are often a source of a major slowdown on the whole infrastructure because people have the bad habits to use the LIKE operator or SQL’s native JSON parsing functions, which are not the best at performances, especially on huge tables.
With the FTS index on the
json_metadata column, instead of writing a query like
SELECTCOUNT(*)FROMCommentsWHEREjson_metadata like '%peakd%'
one can write
The first query will take dozens of minutes to complete whereas the last one will complete in less than 2 seconds!
Full-Text Search is enabled on the
memo column of the TxTransfers table
This will allow you to use the CONTAINS() and FREETEXT() predicate functions to find transfers containing a specific string in their memo.