This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[~/Documents/puppetdb] (ticket/master/pdb-772-change-facts) $ curl -X GET http://localhost:8080/v4/fact-nodes --data-urlencode 'query=["=","name","my_structured_fact"]' | |
[ { | |
"value" : { | |
"f" : "", | |
"b" : { | |
"g" : "", | |
"e" : [ 3.14, 2.71 ], | |
"d" : "bar", | |
"c" : [ 1, 2, 3 ] | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QUERY PLAN | |
--------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Hash Semi Join (cost=157.17..158.98 rows=6 width=209) (actual time=2.153..2.282 rows=115 loops=1) | |
Hash Cond: (fs.certname = certnames.name) | |
-> Sort (cost=104.79..105.08 rows=115 width=219) (actual time=2.076..2.102 rows=115 loops=1) | |
Sort Key: fp.name, fs.certname | |
Sort Method: quicksort Memory: 42kB | |
-> Nested Loop Left Join (cost=62.98..100.86 rows=115 width=219) (actual time=0.335..1.218 rows=115 loops=1) | |
-> Hash Join (cost=62.83..72.30 rows=115 width=195) (actual time=0.318..0.786 rows=115 loops=1) | |
Hash Cond: (fv.value_type_id = vt.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import urllib | |
import json | |
query = '["or",\ | |
["and", ["=", "type", "Class"], ["=", "title", "Php"]],\ | |
["and", ["=", "type", "Class"], ["=", "title", "Nginx"]]]' | |
url = 'http://localhost:8080/v4/resources?%s' % urllib.urlencode({'query': query}) | |
data = json.loads(urllib2.urlopen(url).read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MASTER | |
curl -X GET http://localhost:8080/v4/facts/trusted | |
[ { | |
"value" : { | |
"authenticated" : "remote", | |
"certname" : "mbp.local" | |
}, | |
"name" : "trusted", | |
"environment" : "production", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET http://localhost:8080/v4/fact-nodes --data-urlencode 'query=["=",["name","certname"],["trusted","mbp.local"]]' | |
[ { | |
"certname" : "mbp.local", | |
"path" : [ "trusted", "certname" ], | |
"name" : "trusted", | |
"value" : "mbp.local", | |
"environment" : "production" | |
}, { | |
"certname" : "mbp.local", | |
"path" : [ "trusted", "authenticated" ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET http://localhost:8080/v4/facts --data-urlencode 'query=["in", "name", ["extract", "name", ["select-fact-nodes",["=",["name","certname"],["trusted","mbp.local"]]]]]' | |
[ { | |
"value" : { | |
"authenticated" : "remote", | |
"certname" : "mbp.local" | |
}, | |
"name" : "trusted", | |
"environment" : "production", | |
"certname" : "mbp.local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QUERY PLAN | |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Nested Loop Semi Join (cost=45.17..818.21 rows=3 width=85) (actual time=16.043..22.796 rows=2 loops=1) | |
-> Nested Loop Left Join (cost=44.75..800.09 rows=3 width=85) (actual time=16.019..22.741 rows=2 loops=1) | |
Join Filter: (fs.environment_id = env.id) | |
Rows Removed by Join Filter: 6 | |
-> Nested Loop (cost=44.75..798.86 rows=3 width=89) (actual time=16.007..22.724 rows=2 loops=1) | |
Join Filter: (fp.value_type_id = vt.id) | |
Rows Removed by Join Filter: 10 | |
-> Seq Scan on value_types vt (cost=0.00..1.06 rows=6 width=14) (actual time=0.003..0.005 rows=6 loops=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wyatt=# select * from pg_stat_activity; | |
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | waiting | state | query | |
---------+----------+------+----------+----------+------------------+-------------+-----------------+-------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+---------+--------+--------------------------------------------------------------------------- | |
2095234 | puppetdb | 6475 | 65968 | puppetdb | | 127.0.0.1 | | 51033 | 2014-08-19 16:21:16.738214-07 | <<NULL>> | 2014-08-19 16:21:27.787003-07 | 2014-08-19 16:21:27.797803-07 | f | idle | COMMIT | |
2095234 | puppetdb | 6476 | 65968 | puppetdb | | 127 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITHOUT INDEXES WITH TRGM INDEXES: | |
database size database size | |
schema | name | size | index | ratio | total schema | name | size | index | ratio | total | |
-------------------+------------------------------------+------------+---------+-------+--------- -------------------+------------------------------------+------------+---------+-------+--------- | |
public | fact_values | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXPLAIN ANALYZE | |
delete from fact_values where ID NOT IN (SELECT fact_value_id FROM facts); | |
EXPLAIN ANALYZE | |
delete from fact_paths where ID NOT IN (SELECT path_id FROM fact_values); | |
EXPLAIN ANALYZE | |
delete from resource_params_cache where NOT EXISTS (SELECT * FROM catalog_resources cr WHERE cr.resource=resource_params_cache.resource); | |
EXPLAIN ANALYZE |
OlderNewer