Open vojtad opened 8 years ago
Thanks for this! Can we check for Postgres and only use int8range
if it's present?
I am currently investigating this. I will probably add new column ip_range
to maxmind_geolite_city_blocks
and use it if we are on Postgres. I will update this issue when pull request is ready.
Also, I am not sure whether Rails 3 supports range data types for Postgres or not. I have to check that, too.
Using one int8range column instead of 2 bigint columns for IP range in maxmind_geolite_city_blocks speeds up lookup from ~20 ms to ~0.1 ms. This is really big improvement.
Using 2 bigint columns:
Using int8range:
However, other databases do not support range types.
I would be happy to a create pull request to implement int8range for Postgres but I am not sure how to make other databases compatible. Do you have any ideas or tips? I would like to discuss them in this issue.