cross-apply

cross apply xml query performs exponentially worse as xml document grows

谁说我不能喝 提交于 2019-11-27 05:18:22
What I Have I have a variable size XML document that needs to be parsed on MSSQL 2008 R2 that looks like this: <data item_id_type="1" cfgid="{4F5BBD5E-72ED-4201-B741-F6C8CC89D8EB}" has_data_event="False"> <item name="1"> <field id="{EA032B25-19F1-4C1B-BDDE-3113542D13A5}" type="2">0.506543009706267</field> <field id="{71014ACB-571B-4C72-9C9B-05458B11335F}" type="2">-0.79500402346138</field> <field id="{740C36E9-1988-413E-A1D5-B3E5B4405B45}" type="2">0.0152649050024924</field> </item> <item name="2"> <field id="{EA032B25-19F1-4C1B-BDDE-3113542D13A5}" type="2">0.366096802804087</field> <field id=

Postgres analogue to CROSS APPLY in SQL Server

空扰寡人 提交于 2019-11-26 21:01:43
I need to migrate SQL queries written for MS SQL Server 2005 to Postgres 9.1. What is the best way to substitute for CROSS APPLY in this query? SELECT * FROM V_CitizenVersions CROSS APPLY dbo.GetCitizenRecModified(Citizen, LastName, FirstName, MiddleName, BirthYear, BirthMonth, BirthDay, ..... ) -- lots of params GetCitizenRecModified() function is a table valued function. I can't place code of this function because it's really enormous, it makes some difficult computations and I can't abandon it. Erwin Brandstetter In Postgres 9.3 or later use a LATERAL join: SELECT v.col_a, v.col_b, f.* --

cross apply xml query performs exponentially worse as xml document grows

拈花ヽ惹草 提交于 2019-11-26 11:30:30
问题 What I Have I have a variable size XML document that needs to be parsed on MSSQL 2008 R2 that looks like this: <data item_id_type=\"1\" cfgid=\"{4F5BBD5E-72ED-4201-B741-F6C8CC89D8EB}\" has_data_event=\"False\"> <item name=\"1\"> <field id=\"{EA032B25-19F1-4C1B-BDDE-3113542D13A5}\" type=\"2\">0.506543009706267</field> <field id=\"{71014ACB-571B-4C72-9C9B-05458B11335F}\" type=\"2\">-0.79500402346138</field> <field id=\"{740C36E9-1988-413E-A1D5-B3E5B4405B45}\" type=\"2\">0.0152649050024924<

CROSS/OUTER APPLY in MySQL

送分小仙女□ 提交于 2019-11-26 09:50:36
问题 I need to use CROSS APPLY in MySQL (EC2 RDS MySQL instance). Looks like MySQL doesn\'t recognise the CROSS APPLY Syntax. Can someone help me please? Here\'s the query. SELECT ORD.ID ,ORD.NAME ,ORD.DATE ,ORD_HIST.VALUE FROM ORD CROSS APPLY ( SELECT TOP 1 ORD_HISTORY.VALUE FROM ORD_HISTORY WHERE ORD.ID = ORD_HISTORY.ID AND ORD.DATE <= ORD_HISTORY.DATE ORDER BY ORD_HISTORY.DATE DESC ) ORD_HIST 回答1: Your closest direct approximation is a join with a correlated sub-query as the predicate. SELECT

Postgres analogue to CROSS APPLY in SQL Server

China☆狼群 提交于 2019-11-26 09:03:37
问题 I need to migrate SQL queries written for MS SQL Server 2005 to Postgres 9.1. What is the best way to substitute for CROSS APPLY in this query? SELECT * FROM V_CitizenVersions CROSS APPLY dbo.GetCitizenRecModified(Citizen, LastName, FirstName, MiddleName, BirthYear, BirthMonth, BirthDay, ..... ) -- lots of params GetCitizenRecModified() function is a table valued function. I can\'t place code of this function because it\'s really enormous, it makes some difficult computations and I can\'t

When should I use cross apply over inner join?

て烟熏妆下的殇ゞ 提交于 2019-11-25 23:10:10
问题 What is the main purpose of using CROSS APPLY? I have read (vaguely, through posts on the Internet) that cross apply can be more efficient when selecting over large data sets if you are partitioning. (Paging comes to mind) I also know that CROSS APPLY doesn\'t require a UDF as the right-table. In most INNER JOIN queries (one-to-many relationships), I could rewrite them to use CROSS APPLY , but they always give me equivalent execution plans. Can anyone give me a good example of when CROSS