Share
Embed
Not everything is a damn SQL statement
Slides for my SQL/NoSQL talk at FeWeb Summerevent 2014
Thijs Feryn PRO
June 25, 2014
Transcript
34 slides
-
SQLWELL ✓Normalization ✓No data duplication ✓Flexible DRL/DQL ✓Relations (JOIN, subqueries,
GROUP BY) ✓Everyone knows SQL ✓All RDMBS products speak SQL -
SQLHELL ➡Normalization ➡Bad indexing is heavy on the storage ➡DRL/DQL
is „expensive” ➡Relations & data reassembly ➡Everyone is stuck in the SQL trap ➡SQL is not complete ! -
Content ✓Blog post ✓Log file ✓Invoice ✓Geopoint ✓Bank transaction ✓Webshop
product ✓Realtime data ✓... -
What do you want to do? ✓Full text search ✓Geo
sorting/filtering ✓Data analytics ✓Sorting ✓Rapid retrieval ✓Fast storage ✓Huge datasets -
Opportunity ✓Alternative output ➡JSON, XML, … ✓Restful ✓Features++ ✓More than
storage & retrieval -
Risk ➡Learning curve ➡Storage ➡Lots of RAM ➡No uniformity ➡Data
is „stuck” in a fixed format ➡Mapping? Constraints? -
curl http://weten.dev:9200/_search?pretty -‐d' { "from":
0, "size": 100, "query" : { "filtered" : { "query" : { "match_all" : {} }, "filter" : { "and" : [ { "range": { "@timestamp" : { "from": "2014-‐06-‐02T10:00:00Z", "to": "2014-‐06-‐04T16:00:00Z" } } }, { "term": { "geoip.country_code2.raw": "DE" } } ] } } }, "sort" : [ {"@timestamp" : {"order" : "desc"}} ] }' Query -
{ "took" : 36, "timed_out" :
false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.0, "hits" : [ { "_index" : "logstash-‐2014.06.03", "_type" : "apache", "_id" : "OS81NlYWTQu4j4O5OZMmXA", "_score" : 1.0, "_source":{"tags":[],"@version": 1,"@timestamp":"2014-‐06-‐03T14:37:07.119Z","host":"meten","file":"/var/log/apache2/ access.log","message":"10.10.10.1 -‐ -‐ [03/Jun/2014:14:37:07 +0000] \"GET / HTTP/1.1\" 200 483 \"-‐\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/ 29.0\"","type":"apache","clientip":"217.21.177.69","ident":"-‐","auth":"-‐","timestamp":"03/ Jun/2014:14:37:07 +0000","verb":"GET","request":"/","httpversion":"1.1","response":"200","bytes":"483","referr er":"\"-‐\"","agent":"\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0\"","geoip": {"ip":"217.21.177.69","country_code2":"BE","country_code3":"BEL","country_name":"Belgium","c ontinent_code":"EU","region_name":"08","city_name":"Gentbrugge","latitude": 51.05000000000001,"longitude":3.75,"timezone":"Europe/Brussels","real_region_name":"Oost-‐ Vlaanderen","location":[3.75,51.05000000000001]}} } ] } } Output -
{ "template" : "logstash-‐*", "settings" :
{ "index.refresh_interval" : "5s" }, "mappings" : { "_default_" : { "_all" : {"enabled" : true}, "dynamic_templates" : [ { "string_fields" : { "match" : "*", "match_mapping_type" : "string", "mapping" : { "type" : "string", "index" : "analyzed", "omit_norms" : true, "fields" : { "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256} } } } } ], "properties" : { "@version": { "type": "string", "index": "not_analyzed" }, "geoip" : { "type" : "object", "dynamic": true, "path": "full", "properties" : { "location" : { "type" : "geo_point" } } } } } } } Mapping -
SET key value GET key SET number 2
INCR number INCRBY number 10 APPEND key XYZ HGET key1 field1 HKEYS key1 LLEN key2 SISMEMBER key3 member1