compare_packages_to_snapshot: performance fix

Reduces query time from several minutes to some milliseconds. In a test
environment, speedup was ~2400x.

Results are coherent with Perl code across Oracle and Postgresql according
to tests.