Each ‘Product’ can have as many as 10000 ‘Segment’ rows. The segments have a sort column that starts at 1 for each product (1, 2, 3, 4, 5, …) and a value column that can contain any values such as (323.113, 5423.231, 873.42, 422.64, 763.1, …).
I would like to identify potential matches for products given a subset of segments. For example, if I have 5 segment values in the correct order, how can I efficiently find all the products which have all 5 segments in the same order somewhere in the Segment table?
Update
I posted a follow-up question to this here: Find a series of data using non-exact measurements (fuzzy logic)
Assume tables like so:
Next, set up your search data in a temp table:
For N search objects, this has to be populated like so
Now set up some important values. (This could be crammed into the final query, but this way makes it easier to read, and may improve performance slightly.)
And then it’s just a query:
I am convinced this will work, but I don’t have time to test it out in detail just now. To optimize for performance, besides the primary keys indicated you could add a regular index on Segment.Value