• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

catmaid / CATMAID / 5523 / 2
46%
master: 45%

Build:
Build:
LAST BUILD BRANCH: dev
DEFAULT BRANCH: master
Ran 27 Nov 2018 07:43PM UTC
Files 97
Run time 8s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

27 Nov 2018 07:05PM UTC coverage: 45.573%. Remained the same
5523.2

Pull #1821

travis-ci

web-flow
Enable Posgres trigram extension and add class instance name index

This adds a trigram index to the class_instance table to speed up name
queries that involve wildcards and regular expressions. These are
common, especially in the neuron widget. Since we also allow wildcards
at the end of a name (e.g. when searching for a neuron name), B-tree
can't be used. Trigram however works fine with this and is included in a
regular Postgres setup. It only needs to be enabled through an
extension.

For small instances, these queries are already fast. However on large
instances, sequential scans on the class_instance table can be quite
slow when doing name lookups. For instance, in a large test instance I
have 215,707,715 class instance entries ans looking for a name takes
about ~30 seconds on a heavily optimized Postgres database. Using the
trigram index bring this down to 2 ms (!). The size of this index is
comparable to the foreign key index. The example table has a size of 19
GB, the primary key index is ~4.5 GB and the trigram index ~5 GB. Given
that neuron name search and annotation search is done a lot, I feel this
increase in space requirement is justified.

A simple name search looks like this (typing "aSIP" into the neuron name
search):

  SELECT ci.id, ci.user_id, ci.creation_time, ci.edition_time,
    ci.project_id, ci.class_id, ci.name, skel_link.skeletons
  FROM class_instance ci
  LEFT JOIN LATERAL (
    SELECT cici_n.class_instance_b AS id,
    array_agg(cici_n.class_instance_a) AS skeletons
    FROM class_instance_class_instance cici_n
    WHERE cici_n.class_instance_b = ci.id
    AND cici_n.relation_id = 10
    GROUP BY 1
  ) skel_link ON ci.id = skel_link.id
  WHERE ci.project_id = 1
    AND ci.class_id = ANY (ARRAY[3,6])
    AND ci.name ~~* '%aSIP%'
  ORDER BY id ASC;

The query plan without the trigram index looks like this:

 Sort  (cost=3443312.34..3443339.28 rows=10779 width=83) (actual time=25818.498..25818.498 rows=5 loops=1)
   Sort Key... (continued)
Pull Request #1821: Enable pg_trgm extension and add trigram index for class instance names

7679 of 16850 relevant lines covered (45.57%)

0.46 hits per line

Source Files on job 5523.2
  • Tree
  • List 0
  • Changed 26
  • Source Changed 23
  • Coverage Changed 26
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 5051
  • Travis Job 5523.2
  • 635c3036 on github
  • Prev Job for on features/class-instance-trigram-index (#5520.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc