Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

pg_trgm enables typo-tolerant matching in PostgreSQL by comparing groups of three consecutive characters. In Supabase, enable the extension for your project, add a GiST or GIN trigram index suited to your query, and choose whole-string or word-similarity operators based on what should match. PostgreSQL describes trigram matching as effective for words in many natural languages, but that is not a guarantee of equal accuracy across languages, scripts, or query lengths.

What pg_trgm does—and what it does not do

PostgreSQL defines a trigram as a group of three consecutive characters taken from a string. The pg_trgm extension estimates how similar two strings are by comparing their trigrams. That makes it useful when a user misspells a name or term, or when an application needs to find text resembling a query rather than requiring an exact match. See the PostgreSQL 17 pg_trgm documentation.

Trigram matching is character-based similarity, not translation or language-aware stemming. PostgreSQL says it can be effective for words in many natural languages; the documentation does not establish identical behavior for every language or writing system. It also publishes no language-by-language typo-correction accuracy figures. Test using the languages, scripts, and query lengths your application actually expects.

How to enable pg_trgm in Supabase

Supabase lists pg_trgm among its Postgres extensions. Its documented workflow allows extensions to be installed through the SQL editor or a PostgreSQL client. Availability and extension version can depend on the target project, so check the project rather than assuming the extension is already enabled. The Supabase Postgres Extensions guide also notes that accessing a newly available extension version may require a software upgrade.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  1. Open the Supabase project and consult the Extensions guide to locate the documented extension workflow.
  2. Enable pg_trgm for that project using the SQL editor or a PostgreSQL client, as supported by the project.
  3. Verify installation in the target database. If the extension is unavailable or its version is not the one you need, check the project’s upgrade and extension options before relying on it.

For a SQL-based setup, the PostgreSQL extension command is CREATE EXTENSION pg_trgm;. Run it in the intended database with a role permitted to install extensions. If the extension is already installed, PostgreSQL will report that unless you use IF NOT EXISTS: CREATE EXTENSION IF NOT EXISTS pg_trgm;.

Choose the match semantics before the index

The extension offers whole-string similarity and two word-similarity forms. The right operator depends on whether the query should resemble the entire field, match a word-like extent within a longer field, or return the nearest candidates in distance order. PostgreSQL documents these operators and settings in its PostgreSQL 16 pg_trgm documentation.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Whole-string similarity

similarity(text, text) returns a similarity value. The % operator tests whether the strings’ similarity exceeds the active pg_trgm.similarity_threshold. Use this when a field such as a product name or contact name should be compared as a whole. For example, WHERE name % 'Jon Smyth' filters rows by the current threshold; it does not guarantee that every returned row is a useful result.

Word similarity within a longer value

The word-similarity operators compare the query’s trigram set with a continuous extent of an ordered trigram set from the other string. This can suit a short query word that appears, perhaps imperfectly, inside a longer field. Strict word similarity additionally constrains the matching extent to word boundaries. Choose between them based on whether a partial word-like extent is acceptable or the match should align with a complete word.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Threshold settings are tunable, not accuracy scores

PostgreSQL 16 documents defaults of 0.3 for pg_trgm.similarity_threshold, 0.6 for pg_trgm.word_similarity_threshold, and 0.5 for pg_trgm.strict_word_similarity_threshold. These are configuration defaults—not measured relevance guarantees. A stricter threshold can reduce matches, while a more permissive one can admit more weak matches. Tune and validate thresholds against real application queries rather than treating any default as universally ideal.

GiST or GIN: match the index to the query

Both GiST and GIN trigram operator classes support trigram similarity operations and documented pattern searches. The PostgreSQL 16 documentation names the operator classes gist_trgm_ops and gin_trgm_ops, and documents support for indexed LIKE, ILIKE, regular-expression, and equality searches. Neither index type is a universal speed winner; the appropriate choice depends on workload and relative performance characteristics.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Query shape GiST GIN
Threshold similarity matching Supported by gist_trgm_ops. Supported by gin_trgm_ops.
Documented LIKE, ILIKE, regular-expression, and equality searches Supported. Supported.
Nearest matches ordered by trigram distance, such as ORDER BY name <-> 'query' LIMIT 10 PostgreSQL 16 documents efficient distance-ordered retrieval. PostgreSQL 16 says this query shape cannot be implemented efficiently by GIN.

For ordinary threshold filtering, either index family supports trigram operators. If the central query is a small nearest-neighbor result set ordered by <->, GiST is the documented choice for efficient distance-ordered retrieval. Do not assume the same advantage for a different workload; measure representative queries on your data.

Patterns need extractable trigrams

Indexed pattern searches work best when PostgreSQL can extract useful trigrams from the pattern. The documentation warns that a pattern with no extractable trigrams can degenerate to a full-index scan. Very short patterns may therefore have poor selectivity even when an index exists. An index does not make every substring or pattern query cheap.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Combine trigram matching with full-text search

Full-text search and trigram matching solve related but different problems. A PostgreSQL text-search configuration handles linguistic tokenization and normalization for document retrieval; pg_trgm compares character trigrams. PostgreSQL describes trigram matching as useful alongside a full-text index, particularly for suggesting spellings of misspelled input words that would not directly match. See the PostgreSQL 16 text-search index documentation.

One documented spelling-suggestion design extracts unique, unstemmed words from document text into an auxiliary vocabulary table, using ts_stat with the simple text-search configuration, then creates a GIN trigram index on that vocabulary. The application can compare an input word against the vocabulary and offer similar spellings, while full-text search remains responsible for retrieving documents. PostgreSQL notes that the static vocabulary table needs periodic regeneration to stay reasonably current. This design is a starting point, not a built-in automatic correction system.

Validate behavior for your languages and queries

The claim that trigram matching can be effective in many natural languages should not be read as a promise of uniform multilingual performance. The PostgreSQL documentation provides no comparative benchmarks by language or script, and Supabase’s extension guide does not supply typo-correction accuracy measurements. Before setting production thresholds, test representative records and misspellings from each language your app supports.

  • Include short and long queries, since short strings can provide few useful trigrams.
  • Test names and terms with the scripts, diacritics, and character combinations present in your data.
  • Review both missed relevant results and weak matches introduced by permissive thresholds.
  • Validate the PostgreSQL version and extension version actually available in the target Supabase project; versioned PostgreSQL documentation may describe behavior or defaults for a different deployed version.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.