<p>That's definitely an element selection query.  In order to tell where it's coming from, you'd either have to cross reference the timestamp <code>1471114282</code> or (if devMode is enabled) the query itself against the <code>craft/storage/runtime/logs</code> files.</p>

CC BY-SA 3.0
2016-08-19T20:18:33.870Z
2016-08-19T20:18:33.870Z
Brad Bell
<p>Does anyone have an idea as to what might be causing this query? My only guess is that it has something to do with Element API which we are using on the production site.</p>

<p>This is locking up the database and seems to coincide with a series of other malicious XSS requests.</p>

<p>Got this from MySQL Slow Query Log - 548190019 rows examined.</p>

<pre><code>SET timestamp=1471114282;
SELECT `elements`.`id`, `elements`.`type`, `elements`.`enabled`, `elements`.`archived`, `elements`.`dateCreated`, `ele
ments`.`dateUpdated`, `elements_i18n`.`slug`, `elements_i18n`.`uri`, `elements_i18n`.`enabled` AS `localeEnabled`, `co
ntent`.`id` AS `contentId`, `content`.`title`, `content`.`field_allowCrop`, `content`.`field_imgAltText`, `content`.`f
ield_backgroundColor`, `content`.`field_blockTemplate`, `content`.`field_blogAuthor`, `content`.`field_blockLink`, `co
ntent`.`field_buttonColor`, `content`.`field_buttonStyle`, `content`.`field_certificationActivity`, `content`.`field_c
olor`, `content`.`field_blockContent`, `content`.`field_continents`, `content`.`field_countries`, `content`.`field_cta
Text`, `content`.`field_description`, `content`.`field_propertyDesc`, `content`.`field_protectedDescription`, `content
`.`field_eventLocation`, `content`.`field_eventUrl`, `content`.`field_externalLink`, `content`.`field_protectedExterna
lUrl`, `content`.`field_feature`, `content`.`field_featuredResource`, `content`.`field_protectedType`, `content`.`fiel
d_firstName`, `content`.`field_formCode`, `content`.`field_formUrl`, `content`.`field_heading`, `content`.`field_heroL
ink`, `content`.`field_footHtml`, `content`.`field_bodyHtmlTop`, `content`.`field_headHtml`, `content`.`field_exampleH
tmlEmailBody`, `content`.`field_iconColor`, `content`.`field_iconPosition`, `content`.`field_lastName`, `content`.`fie
ld_mediaContacts`, `content`.`field_seoMaticMeta`, `content`.`field_new`, `content`.`field_oldId`, `content`.`field_pa
geTemplate`, `content`.`field_podcastDescription`, `content`.`field_podcastKeywords`, `content`.`field_podcastLength`, `content`.`field_podcastSubtitle`, `content`.`field_position`, `content`.`field_promoLink`, `content`.`field_quote`, `content`.`field_quoteSource`, `content`.`field_resource`, `content`.`field_featuredResourceText`, `content`.`field_shortDescription`, `content`.`field_tagline`, `content`.`field_taglinePosition`, `content`.`field_textColor`, `content`.`field_exampleTextEmailBody`, `content`.`field_tripleNet`, `content`.`field_videoUrl`, `entries`.`sectionId`, `entries`.`typeId`, `entries`.`authorId`, `entries`.`postDate`, `entries`.`expiryDate`, `structureelements`.`root`, `structureelements`.`lft`, `structureelements`.`rgt`, `structureelements`.`level`
FROM `craft_elements` `elements`
JOIN `craft_elements_i18n` `elements_i18n` ON elements_i18n.elementId = elements.id
JOIN `craft_content` `content` ON content.elementId = elements.id
LEFT JOIN `craft_relations` `sources1` ON (sources1.targetId = elements.id)
LEFT JOIN `craft_relations` `targets1` ON (targets1.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources2` ON (sources2.targetId = elements.id)
LEFT JOIN `craft_relations` `targets2` ON (targets2.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources3` ON (sources3.targetId = elements.id)
LEFT JOIN `craft_relations` `targets3` ON (targets3.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources4` ON (sources4.targetId = elements.id)
LEFT JOIN `craft_relations` `targets4` ON (targets4.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources5` ON (sources5.targetId = elements.id)
LEFT JOIN `craft_relations` `targets5` ON (targets5.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources6` ON (sources6.targetId = elements.id)
LEFT JOIN `craft_relations` `targets6` ON (targets6.sourceId = elements.id)
JOIN `craft_entries` `entries` ON entries.id = elements.id
JOIN `craft_sections` `sections` ON sections.id = entries.sectionId
LEFT JOIN `craft_structures` `structures` ON structures.id = sections.structureId
LEFT JOIN `craft_structureelements` `structureelements` ON (structureelements.structureId = structures.id) AND (structureelements.elementId = entries.id)
WHERE ((((((elements_i18n.locale = 'en_us') AND (content.locale = 'en_us')) AND (elements.archived = 0)) AND ((elements.enabled = 1) AND (elements_i18n.enabled = 1) AND (entries.postDate &lt;= '2016-08-13 18:11:07') AND ((entries.expiryDate is null) OR (entries.expiryDate &gt; '2016-08-13 18:11:07')))) AND (elements_i18n.enabled = 1)) AND (((sources1.sourceId='3103') OR (targets1.targetId='3103')) OR ((sources2.sourceId='3104') OR (targets2.targetId='3104')) OR ((sources3.sourceId='3107') OR (targets3.targetId='3107')) OR ((sources4.sourceId='3108') OR (targets4.targetId='3108')) OR ((sources5.sourceId='4694') OR (targets5.targetId='4694')) OR ((sources6.sourceId='3109') OR (targets6.targetId='3109')))) AND (sections.handle='properties')
GROUP BY `elements`.`id`
ORDER BY `lft`, `postDate` DESC LIMIT 100;```
</code></pre>

<plugin-elementapi><mysql><query>
What is creating this huge query?
# What is creating this huge query?

(Asked by: username_0 on 2016-08-19)

Does anyone have an idea as to what might be causing this query? My only guess is that it has something to do with Element API which we are using on the production site.
This is locking up the database and seems to coincide with a series of other malicious XSS requests.
Got this from MySQL Slow Query Log - 548190019 rows examined.
SET timestamp=1471114282;
SELECT `elements`.`id`, `elements`.`type`, `elements`.`enabled`, `elements`.`archived`, `elements`.`dateCreated`, `ele
ments`.`dateUpdated`, `elements_i18n`.`slug`, `elements_i18n`.`uri`, `elements_i18n`.`enabled` AS `localeEnabled`, `co
ntent`.`id` AS `contentId`, `content`.`title`, `content`.`field_allowCrop`, `content`.`field_imgAltText`, `content`.`f
ield_backgroundColor`, `content`.`field_blockTemplate`, `content`.`field_blogAuthor`, `content`.`field_blockLink`, `co
ntent`.`field_buttonColor`, `content`.`field_buttonStyle`, `content`.`field_certificationActivity`, `content`.`field_c
olor`, `content`.`field_blockContent`, `content`.`field_continents`, `content`.`field_countries`, `content`.`field_cta
Text`, `content`.`field_description`, `content`.`field_propertyDesc`, `content`.`field_protectedDescription`, `content
`.`field_eventLocation`, `content`.`field_eventUrl`, `content`.`field_externalLink`, `content`.`field_protectedExterna
lUrl`, `content`.`field_feature`, `content`.`field_featuredResource`, `content`.`field_protectedType`, `content`.`fiel
d_firstName`, `content`.`field_formCode`, `content`.`field_formUrl`, `content`.`field_heading`, `content`.`field_heroL
ink`, `content`.`field_footHtml`, `content`.`field_bodyHtmlTop`, `content`.`field_headHtml`, `content`.`field_exampleH
tmlEmailBody`, `content`.`field_iconColor`, `content`.`field_iconPosition`, `content`.`field_lastName`, `content`.`fie
ld_mediaContacts`, `content`.`field_seoMaticMeta`, `content`.`field_new`, `content`.`field_oldId`, `content`.`field_pa
geTemplate`, `content`.`field_podcastDescription`, `content`.`field_podcastKeywords`, `content`.`field_podcastLength`, `content`.`field_podcastSubtitle`, `content`.`field_position`, `content`.`field_promoLink`, `content`.`field_quote`, `content`.`field_quoteSource`, `content`.`field_resource`, `content`.`field_featuredResourceText`, `content`.`field_shortDescription`, `content`.`field_tagline`, `content`.`field_taglinePosition`, `content`.`field_textColor`, `content`.`field_exampleTextEmailBody`, `content`.`field_tripleNet`, `content`.`field_videoUrl`, `entries`.`sectionId`, `entries`.`typeId`, `entries`.`authorId`, `entries`.`postDate`, `entries`.`expiryDate`, `structureelements`.`root`, `structureelements`.`lft`, `structureelements`.`rgt`, `structureelements`.`level`
FROM `craft_elements` `elements`
JOIN `craft_elements_i18n` `elements_i18n` ON elements_i18n.elementId = elements.id
JOIN `craft_content` `content` ON content.elementId = elements.id
LEFT JOIN `craft_relations` `sources1` ON (sources1.targetId = elements.id)
LEFT JOIN `craft_relations` `targets1` ON (targets1.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources2` ON (sources2.targetId = elements.id)
LEFT JOIN `craft_relations` `targets2` ON (targets2.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources3` ON (sources3.targetId = elements.id)
LEFT JOIN `craft_relations` `targets3` ON (targets3.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources4` ON (sources4.targetId = elements.id)
LEFT JOIN `craft_relations` `targets4` ON (targets4.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources5` ON (sources5.targetId = elements.id)
LEFT JOIN `craft_relations` `targets5` ON (targets5.sourceId = elements.id)
LEFT JOIN `craft_relations` `sources6` ON (sources6.targetId = elements.id)
LEFT JOIN `craft_relations` `targets6` ON (targets6.sourceId = elements.id)
JOIN `craft_entries` `entries` ON entries.id = elements.id
JOIN `craft_sections` `sections` ON sections.id = entries.sectionId
LEFT JOIN `craft_structures` `structures` ON structures.id = sections.structureId
LEFT JOIN `craft_structureelements` `structureelements` ON (structureelements.structureId = structures.id) AND (structureelements.elementId = entries.id)
WHERE ((((((elements_i18n.locale = 'en_us') AND (content.locale = 'en_us')) AND (elements.archived = 0)) AND ((elements.enabled = 1) AND (elements_i18n.enabled = 1) AND (entries.postDate <= '2016-08-13 18:11:07') AND ((entries.expiryDate is null) OR (entries.expiryDate > '2016-08-13 18:11:07')))) AND (elements_i18n.enabled = 1)) AND (((sources1.sourceId='3103') OR (targets1.targetId='3103')) OR ((sources2.sourceId='3104') OR (targets2.targetId='3104')) OR ((sources3.sourceId='3107') OR (targets3.targetId='3107')) OR ((sources4.sourceId='3108') OR (targets4.targetId='3108')) OR ((sources5.sourceId='4694') OR (targets5.targetId='4694')) OR ((sources6.sourceId='3109') OR (targets6.targetId='3109')))) AND (sections.handle='properties')
GROUP BY `elements`.`id`
ORDER BY `lft`, `postDate` DESC LIMIT 100;```

**Tags:** plugin-elementapi, mysql, query


---

## 1 answers

### Answer by username_1 on 2016-08-19. Score: 2

That's definitely an element selection query. In order to tell where it's coming from, you'd either have to cross reference the timestamp `1471114282` or (if devMode is enabled) the query itself against the `craft/storage/runtime/logs` files.


---

