• Yorick Peterse's avatar
    Use ILIKE/LIKE + UNION in Project.search · 135659a7
    Yorick Peterse authored
    This chance is broken up in two steps:
    
    1. Use ILIKE on PostgreSQL and LIKE on MySQL, instead of using
       "WHERE lower(x) LIKE lower(y)" as ILIKE is significantly faster than
       using lower(). In many cases the use of lower() will force a slow
       sequence scan.
    
    2. Instead of using 1 query that searches both projects and namespaces
       using a JOIN we're using 2 separate queries that are UNION'd
       together. Using a JOIN would force a slow sequence scan, using a
       UNION avoids this.
    
    This method now uses Arel as Arel automatically uses ILIKE on PostgreSQL
    and LIKE on MySQL, removing the need to handle this manually.
    135659a7
project.rb 27.5 KB