documentation:tutorials:json_query
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
documentation:tutorials:json_query [2013/02/26 17:48] – this is a rough conversion from openoffice format lebbeous | documentation:tutorials:json_query [2022/02/10 13:34] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 115: | Line 115: | ||
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | - Every column is aliased with the column name. There is a way to choose a different column alias (not shown here). | + | |
+ | * Every column is aliased with the column name. There is a way to choose a different column alias (not shown here). | ||
===== The SELECT clause ===== | ===== The SELECT clause ===== | ||
Line 187: | Line 186: | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
This example assigns a different column alias: | This example assigns a different column alias: | ||
Line 2087: | Line 2086: | ||
JOIN actor.org_unit AS s ON (t.source = s.id) | JOIN actor.org_unit AS s ON (t.source = s.id) | ||
JOIN actor.org_unit AS d ON (t.dest = d.id) | JOIN actor.org_unit AS d ON (t.dest = d.id) | ||
- | WHERE s.parent_ou< | + | WHERE s.parent_ou <> d.parent_ou ) AS " |
</ | </ | ||
Line 2095: | Line 2094: | ||
+ | ==== Choosing the Order of JOINs ==== | ||
+ | |||
+ | As of Evergreen 3.0.2, we support user-defined join order in cstore and friends. Previously, because the join structure of '' | ||
+ | |||
+ | For example, given the following JSON object passing through a modern Perl 5 interpreter as a nested hash: | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | select : { | ||
+ | acp: [' | ||
+ | acn: [' | ||
+ | acpl: [' | ||
+ | }, | ||
+ | from : { | ||
+ | acp: { | ||
+ | acn: {filter: {record: 12345} }, | ||
+ | acpl: null | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | the FROM clause of the query may end up as: | ||
+ | |||
+ | <code sql> | ||
+ | FROM acp | ||
+ | JOIN acn ON (acp.call_number = acn.id AND acn.record = 12345) | ||
+ | JOIN acpl ON (acp.location = acpl.id) | ||
+ | </ | ||
+ | |||
+ | Or as: | ||
+ | |||
+ | <code sql> | ||
+ | FROM acp | ||
+ | JOIN acpl ON (acp.location = acpl.id) | ||
+ | JOIN acn ON (acp.call_number = acn.id AND acn.record = 12345) | ||
+ | </ | ||
+ | |||
+ | In some situations, the join order will matter either to the semantics of the query plan, or to its performance. The following example of the newly supported syntax illustrates how to specify join order: | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | select : { | ||
+ | acp: [' | ||
+ | acn: [' | ||
+ | acpl: [' | ||
+ | }, | ||
+ | from : { | ||
+ | acp: [ | ||
+ | {acn: {filter: {record: 12345} } }, | ||
+ | ' | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | And the only FROM clause the can be generated is: | ||
+ | |||
+ | <code sql> | ||
+ | FROM acp | ||
+ | JOIN acn ON (acp.call_number = acn.id AND acn.record = 12345) | ||
+ | JOIN acpl ON (acp.location = acpl.id) | ||
+ | </ | ||
==== Things You Can't Do ==== | ==== Things You Can't Do ==== | ||
documentation/tutorials/json_query.1361918936.txt.gz · Last modified: 2022/02/10 13:33 (external edit)