I have a table called geo_location
which keeps public ip range
in the city( in integer form). I have to query an ip
in the table and check if it lies between start_range
and end_range
and then return the corresponding row. The table has 2929393 rows
.
Here is my table descriptin:
CREATE TABLE acrs.geo_location (
start_range bigint,
end_range bigint,
city text,
country text,
country_init text,
latitude double,
longitude double,
state text,
PRIMARY KEY (start_range, end_range)
) WITH CLUSTERING ORDER BY (end_range ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
And this is the example data in the table:
@ Row 1
--------------+---------------------------------
start_range | 3753640192
end_range | 3753640447
city | Tonk
country | India
country_init | IN
latitude | 26.16667
longitude | 75.78333
state | Rajasthan
@ Row 2
--------------+---------------------------------
start_range | 1358168576
end_range | 1358171135
city | Kent
country | United Kingdom
country_init | GB
latitude | 51.25
longitude | 0.75
state | England
Now when I query:
select * from geo_location where start_range < 2534358817 and end_range > 2534358817 ALLOW FILTERING ;
it takes a lot of time before returning the resultant row. It's possible that my data model is not right since I have recently shifted from relational databases to this, hence looking for some help regarding the same. Thanks.