Tag Info

New answers tagged

0

PL/PgSQL will do the job. DO $$ DECLARE _e record; _personid bigint; _suppersonid bigint; _teamid bigint; BEGIN FOR _e IN SELECT ident, name, supervisor_name FROM employee LOOP -- insert person record for employee INSERT INTO person (name, old_ident) SELECT _e.name, _e.ident RETURNING id INTO _personid; -- lookup or ...


9

But the execution plan for both is same as shown below: The plans are different. One is an inner join, the other is an outer join. The results may be the same in your simple test, but the semantics are different. In more complex queries, the difference may cause more obviously different execution plans, and come with a performance impact. There are ...


1

My dilemma is about utility and advantages of using CROSS APPLY and CTE. Are there any or its just exotic? For small datasets the optimizer is probably not bothering with extensive analysis. However, if one were to look at competing plans for large data sets (say millions of Orders or Items from your example), then CROSS APPLY, especially if Items are ...



Top 50 recent answers are included