[pg_trgm] Per-query set_limit()

Started by Greg Navisalmost 10 years ago2 messagesgeneral
Jump to latest
#1Greg Navis
contact@gregnavis.com

Hey!

I'd like to call `set_limit` on a per-query basis, i.e. searching for
restaurants in a given city should use 0.4 and searching for cinemas by
name should use 0.2. I can accomplish this with:

```
SELECT set_limit(0.2);
SELECT * FROM cinemas WHERE name % ?;
```

(similarly for restaurants).

My question is: is there a better way?

Best regards
--
Greg Navis
I help tech companies to scale Heroku-hosted Rails apps.
Free, biweekly scalability newsletter for SaaS CEOs
<http://www.gregnavis.com/newsletter/&gt;

#2Arthur Zakirov
a.zakirov@postgrespro.ru
In reply to: Greg Navis (#1)
Re: [pg_trgm] Per-query set_limit()

Unfortunately, there is not a better way. You should manually set it if
you want different limit.

On 03.06.2016 13:43, Greg Navis wrote:

Hey!

I'd like to call `set_limit` on a per-query basis, i.e. searching for
restaurants in a given city should use 0.4 and searching for cinemas by
name should use 0.2. I can accomplish this with:

```
SELECT set_limit(0.2);
SELECT * FROM cinemas WHERE name % ?;
```

(similarly for restaurants).

My question is: is there a better way?

Best regards
--
Greg Navis
I help tech companies to scale Heroku-hosted Rails apps.
Free, biweekly scalability newsletter for SaaS CEOs
<http://www.gregnavis.com/newsletter/&gt;

--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general