Checking the subset sum set problem with set processing

May 16, 2011
Author
Justin Swanhart
Share this Post:

Hi,

Here is an easy way to run the subset sum check from SQL, which you can then distribute with Shard-Query:

Notice there is no 16 in the list. We did not pass the check. There are enough 15s though. The distinct value count for each item in the output set, must at least match the cardinality of each item in the input set).

Notice that I have a lot of numbers in my list:

Now insert a value which will cause our check to pass:

Of course, I can use a materialized view and check the expression in subsecond.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved