add ability to set the result set distinct
Description
Environment
Potential Workaround
Checklist
hideTestRail: Results
Activity

shale99July 15, 2018 at 6:28 PM
,
include the distinct in the fields you request - "distinct(_id),jsonb"
with sorting (include the sort field in the selected fields - "distinct(_id),jsonb,lower(f_unaccent(jsonb->>'title'))"
Important points:
1. in order for things like item.barcode queries to work at millisecond response time we need another view in inv-storage. The very very IMPORTANT take on how to create a view depends on the way it will be queried. If you want to query on item.barcode, you need a view whose main table is item. running distinct on that will be super fast as well (see view definition below).
2. IF you are querying on multiple fields across multiple tables in the join - it will usually work really well as the filters of the where clauses are first applied to each table before it is joined which (if the filter reduces the amount of retrieved records to a normal amount) will return quickly
3. running on the instance , holdings , item view (3 table join) where you are querying on item.barcode will take 6-8 seconds. however, if you need a specific record, adding a LIMIT 1 can reduce the 6-8 seconds to 100 milliseconds
the join which will allow item.barcode queries to return in milliseconds on larger tables (tested with data in the item, instance and holdings table)
4. if there is a need to query with constraints on 2 tables and performance is slow on the join view, the current solution would need to be a UNION query , this however is a bit more involved to implement
please verify
to provide more information.