Skip to content

Instantly share code, notes, and snippets.

@rafatower
rafatower / query1.sql
Created September 25, 2019 08:34
Tile query
SELECT the_geom_webmercator, numfloors
FROM public.mappluto_18v2_1
WHERE ((the_geom_webmercator OPERATOR(public.&&) $1::public.geometry))
@rafatower
rafatower / README.md
Last active February 14, 2017 16:54
PostgreSQL stats benchmark

PostgreSQL stats benchmark

A script to benchmark execution time and accuracy of postgres stats generation, in particular for row count estimations.

This is the query used to populate the table (with different sizes):

INSERT INTO test_row_estimation
  SELECT my_id, ST_SetSRID(ST_MakePoint(0,0),4326), my_id, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
  FROM generate_series(1, 1000) AS my_id;
@rafatower
rafatower / city_country_guessing.csv
Created June 21, 2016 17:16
Another silly guessing example
City Country
Madrid Spain
Paris France
Berlin Germany
cartodb_id the_geom name description
2 0101000020E610000000000000000026400000000000002640
1 0101000020E610000000000000000036400000000000003640
country latitude longitude name
AD 42.546245 1.601554 Andorra
AE 23.424076 53.847818 United Arab Emirates
AF 33.93911 67.709953 Afghanistan
AG 17.060816 -61.796428 Antigua and Barbuda
AI 18.220554 -63.068615 Anguilla
AL 41.153332 20.168331 Albania
AM 40.069099 45.038189 Armenia
AN 12.226079 -69.060087 Netherlands Antilles
AO -11.202692 17.873887 Angola
city state zip country
Uxbridge MA 01569 USA
Upton MA 01568 USA
Dudley Hill MA 01570 USA
#!/usr/bin/env python
# Simulation to determine effective qps when the server is faster than MAX_QPS
MAX_QPS = 10.0
MAX_CLIENT_QPS = 50.0
N_REQUESTS = 5000
# A buffer to check the last N request timestamps
request_times = []
@rafatower
rafatower / issue117
Created August 20, 2015 10:54
issue 117 trace
# SELECT cartodb.CDB_CartodbfyTable('public'::TEXT,'public.public'::REGCLASS);
LOG: statement: SELECT cartodb.CDB_CartodbfyTable('public'::TEXT,'public.public'::REGCLASS);
NOTICE: trigger "track_updates" for table "public" does not exist, skipping
CONTEXT: SQL statement "DROP TRIGGER IF EXISTS track_updates ON public"
PL/pgSQL function _cdb_drop_triggers(regclass) line 7 at EXECUTE statement
SQL statement "SELECT _CDB_drop_triggers(reloid)"
PL/pgSQL function cdb_cartodbfytable(text,regclass) line 38 at PERFORM
NOTICE: trigger "update_the_geom_webmercator_trigger" for table "public" does not exist, skipping
CONTEXT: SQL statement "DROP TRIGGER IF EXISTS update_the_geom_webmercator_trigger ON public"
PL/pgSQL function _cdb_drop_triggers(regclass) line 11 at EXECUTE statement
random_string random_figure
repellendus $347,437.09
at $561,466.68
nobis $47,234.47
nobis $563,762.22
repudiandae $389,504.03
ratione $786,262.85
reiciendis $763,971.47
sit $585,583.30
rerum $406,028.21
#!/usr/bin/env ruby
require 'redis'
require 'memcache'
require 'securerandom'
require 'benchmark'
NKEYS=1000
VALUE_LENGTH=3500
REDIS_TESTDB=15 # anything not used yet