database - Improve the speed of locating a row (integer columns) -
i have 15 integer column 5,000,000 rows in table. given input record containing 15 integers need compare input record 5,000,000 record table , obtain matching rows.
note1: integers within row unique
note2: order of columns matching , input record not important.
example: 1, 10, 15, 23, 9, 22, 99, 11, 19, 32, 45, 21, 76, 12, 33 , 33, 10, 15, 99, 11, 19, 32, 45, 21, 23, 9, 22, 76, 12, 1 should yield match result
is possible implement hashing function / bitwise operation generate unique index each row. function can return same index 2 rows if values in records same
this isn't much, should started.
you want hash function generates few collisions possible; has commutative (ie: order in add numbers hash irrelevant). can accomplish using combination of xor's , bit shifts (see page).
you might want store hash in column. can hash input looking , lookup hash on database. note hashes allow false positives, you'd still need check if candidate rows want (ie: sort , compare).
Comments
Post a Comment