Open surfcast23 opened 9 years ago
Without DISTINCT, the query plan looks perfectly fine.
Here's a shorter version of the problematic query that won't time out even if corrected:
SELECT DISTINCT f.size, mt.mass, r.zred FROM MDR1.FOFMtree mt, MDR1.FOF f, MDR1.Redshifts r WHERE mt.fofTreeId between 100000000 and 100000010 AND mt.fofId = f.fofId AND r.snapnum = f.snapnum
with the query plan (Problem lies in select-list of 2. paquExec-call):
-- CALL paquExec('SELECT DISTINCT `mt`.`mass` AS `mt.mass`,`mt`.`fofTreeId` AS `mt.fofTreeId`,`mt`.`fofId` AS `mt.fofId` FROM MDR1.FOFMtree AS `mt` WHERE ( `mt`.`fofTreeId` between 100000000 and 100000010 ) ', 'aggregation_tmp_16214685')
-- CALL paquExec('SELECT `f`.`size` AS `f.size`,`f`.`fofId` AS `f.fofId`,`f`.`snapnum` AS `f.snapnum`,`mt`.`mt.` AS ``,`mt`.`mt.mass` AS `mt.mass` FROM MDR1.FOF AS `f` JOIN ( SELECT DISTINCT `mt.mass`,`mt.fofTreeId`,`mt.fofId` FROM `aggregation_tmp_16214685` ) AS `mt` WHERE ( `mt`.`mt.fofId` = `f`.`fofId` ) ', 'aggregation_tmp_47789533')
-- CALL paquExec('SELECT `r`.`zred` AS `r.zred`,`f`.`f.size` AS `f.size`,`f`.`mt.mass` AS `mt.mass` FROM MDR1.Redshifts AS `r` JOIN ( SELECT `f.size`,`f.fofId`,`f.snapnum`,``,`mt.mass` FROM `aggregation_tmp_47789533` ) AS `f` WHERE ( `r`.`snapnum` = `f`.`f.snapnum` ) ', 'aggregation_tmp_43368652')
-- CALL paquDropTmp('aggregation_tmp_16214685')
-- CALL paquDropTmp('aggregation_tmp_47789533')
-- USE spider_tmp_shard
-- SET @i=0
-- CREATE TABLE cosmosim_user_kristin.`2014-11-06-09-37-01-6478` ENGINE=MyISAM SELECT @i:=@i+1 AS `row_id`, `r.zred`,`f.size`,`mt.mass` FROM `aggregation_tmp_43368652`
-- CALL paquDropTmp('aggregation_tmp_43368652')
HI Kristin,
I still get this error when running the above query
Unknown column 'mt.mt.' in 'field list'
I think its happens where I have marked it in bold below.
mt
.mass
AS mt.mass
,mt
.fofTreeId
AS
mt.fofTreeId
,mt
.fofId
AS mt.fofId
FROM MDR1.FOFMtree AS mt
WHERE
( mt
.fofTreeId
between 100000000 and 1000010000 ) ',
'aggregation_tmp14237518')-- CALL paquExec('SELECT f
.size
AS
f.size
,f
.fofId
AS f.fofId
,f
.snapnum
AS f.snapnum
,mt
.mt_.
AS*,`mt`.`mt.mass`* AS`mt.mass`FROM MDR1.FOF AS`f`JOIN ( SELECT DISTINCT`mt.mass`,`mt.fofTreeId`,`mt.fofId`FROM `aggregation_tmp_14237518`) AS`mt`WHERE (`mt`.`mt.fofId`=`f`.`fofId` ) ', 'aggregation_tmp_91079474')-- CALL paquExec('SELECT`r`.`zred`AS `r.zred`,`f`.`f.size`AS`f.size`,`f`.`mt.mass`AS`mt.mass`FROM MDR1.Redshifts AS`r`JOIN ( SELECT `f.size`,`f.fofId`,`f.snapnum`,
,mt.mass
FROMaggregation_tmp_91079474
) ASf
WHERE (r
.snapnum
=f
.f.snapnum
) ',
'aggregation_tmp_64297027')-- CALL
paquDropTmp('aggregation_tmp_14237518')-- CALL
paquDropTmp('aggregation_tmp_91079474')-- USE spider_tmp_shard-- SET @i=0--
CREATE TABLE cosmosim_user_surfcast23.2014-12-02-23-45-54-3924
ENGINE=MyISAM SELECT @i:=@i+1 ASrow_id
,r.zred
,f.size
,mt.mass
FROM
aggregation_tmp_64297027
-- CALL paquDropTmp('aggregation_tmp_64297027')Thank you
Khary
On Thu, Nov 6, 2014 at 3:47 AM, Kristin Riebe notifications@github.com wrote:
Without DISTINCT, the query plan looks perfectly fine.
Here's a shorter version of the problematic query that won't time out even if corrected:
SELECT DISTINCT f.size, mt.mass, r.zred FROM MDR1.FOFMtree mt, MDR1.FOF f, MDR1.Redshifts r WHERE mt.fofTreeId between 100000000 and 100000010 AND mt.fofId = f.fofId AND r.snapnum = f.snapnum
with the query plan (Problem lies in select-list of 2. paquExec-call):
-- CALL paquExec('SELECT DISTINCT
mt
.mass
ASmt.mass
,mt
.fofTreeId
ASmt.fofTreeId
,mt
.fofId
ASmt.fofId
FROM MDR1.FOFMtree ASmt
WHERE (mt
.fofTreeId
between 100000000 and 100000010 ) ', 'aggregation_tmp_16214685') -- CALL paquExec('SELECTf
.size
ASf.size
,f
.fofId
ASf.fofId
,f
.snapnum
ASf.snapnum
,mt
.mt.
AS,
mt.
mt.massAS
mt.massFROM MDR1.FOF AS
fJOIN ( SELECT DISTINCT
mt.mass,
mt.fofTreeId,
mt.fofIdFROM
aggregation_tmp_16214685) AS
mtWHERE (
mt.
mt.fofId=
f.
fofId) ', 'aggregation_tmp_47789533') -- CALL paquExec('SELECT
r.
zredAS
r.zred,
f.
f.sizeAS
f.size,
f.
mt.massAS
mt.massFROM MDR1.Redshifts AS
rJOIN ( SELECT
f.size,
f.fofId,
f.snapnum,
,mt.mass
FROMaggregation_tmp_47789533
) ASf
WHERE (r
.snapnum
=f
.f.snapnum
) ', 'aggregation_tmp_43368652') -- CALL paquDropTmp('aggregation_tmp_16214685') -- CALL paquDropTmp('aggregation_tmp_47789533') -- USE spider_tmp_shard -- SET @i=0 -- CREATE TABLE cosmosim_user_kristin.2014-11-06-09-37-01-6478
ENGINE=MyISAM SELECT @i:=@i+1 ASrow_id
,r.zred
,f.size
,mt.mass
FROMaggregation_tmp_43368652
-- CALL paquDropTmp('aggregation_tmp_43368652')— Reply to this email directly or view it on GitHub https://github.com/adrpar/paqu/issues/28#issuecomment-61943519.
StriperCoast SurfCasters Club
Hi Khary, well, yes. My example causes the same problem as yours. It's just a shorter version, thus better suited for testing. If my query is fixed, yours will be fixed as well.
By the way, for anyone stumbling across this here: the original query was intended to match snapshot numbers (snapnum) and redshifts for progenitors of a halo. This can be done easier (and without causing headaches for PaQu) for one example halo like this:
SELECT mt.*,z.zred FROM MDR1.FOFMtree AS mt,
(SELECT DISTINCT treeSnapnum, zred FROM MDR1.TreeSnapnums) AS z
WHERE
mt.fofTreeId BETWEEN 100000000 AND
(SELECT lastProgId FROM MDR1.FOFMtree WHERE fofTreeId = 100000000)
AND mt.treeSnapnum = z.treeSnapnum AND mt.np>1000
ORDER BY mt.fofTreeId
When I try to get distinct columns from the following tables, Redshifts, FOF, FOFMtree I get this error
Unknown column 'r.r.' in 'field list'
Query as follows
SELECT DISTINCT mt.*, f.*, r.* FROM MDR1.FOFMtree mt, MDR1.FOF f, MDR1.Redshifts r WHERE mt.fofId = f.fofId AND r.snapnum = f.snapnum AND f.mass = mt.mass
QUERY PLAN
-- The query plan used to run this query: -------------------------------------------------- CALL paquExec('SELECT DISTINCT
r.
snapnumAS
rsnapnum,
r.
aexpAS
raexp,
r.
zredAS
rzredFROM MDR1.Redshifts AS
r', 'aggregation_tmp_73042841')-- CALL paquExec('SELECT
f.
fofIdAS
ffofId,
f.
snapnumAS
fsnapnum,
f.
levelAS
flevel,
f.
NInFileAS
fNInFile,
f.
xAS
fx,
f.
yAS
fy,
f.
zAS
fz,
f.
vxAS
fvx,
f.
vyAS
fvy,
f.
vzAS
fvz,
f.
npAS
fnp,
f.
massAS
fmass,
f.
sizeAS
fsize,
f.
dispAS
fdisp,
f.
disp_vAS
f__disp_v,
f.
deltaAS
fdelta,
f.
spinAS
fspin,
f.
angMom_xAS
fangMom_x,
f.
angMom_yAS
fangMom_y,
f.
angMom_zAS
f__angMom_z,
f.
angMomAS
fangMom,
f.
axis1AS
faxis1,
f.
axis2AS
faxis2,
f.
axis3AS
faxis3,
f.
axis1_xAS
faxis1_x,
f.
axis1_yAS
faxis1_y,
f.
axis1_zAS
faxis1_z,
f.
axis2_xAS
faxis2_x,
f.
axis2_yAS
faxis2_y,
f.
axis2_zAS
faxis2_z,
f.
axis3_xAS
faxis3_x,
f.
axis3_yAS
faxis3_y,
f.
axis3_zAS
f__axis3_z,
f.
ixAS
fix,
f.
iyAS
fiy,
f.
izAS
fiz,
f.
phkeyAS
fphkey,
r.
r.AS``,
r.
rsnapnumAS
rsnapnum,
r.
raexpAS
raexp,
r.
rzredAS
rzredFROM MDR1.FOF AS
fJOIN ( SELECT DISTINCT
rsnapnum,
raexp,
rzredFROM
aggregation_tmp_73042841) AS
rWHERE (
r.
rsnapnum=
f.
snapnum) ', 'aggregation_tmp_31621782')-- CALL paquExec('SELECT
mt.
fofTreeIdAS
mtfofTreeId,
mt.
fofIdAS
mtfofId,
mt.
treeSnapnumAS
mttreeSnapnum,
mt.
descendantIdAS
mtdescendantId,
mt.
lastProgIdAS
mtlastProgId,
mt.
mainLeafIdAS
mtmainLeafId,
mt.
treeRootIdAS
mttreeRootId,
mt.
xAS
mtx,
mt.
yAS
mty,
mt.
zAS
mtz,
mt.
vxAS
mtvx,
mt.
vyAS
mtvy,
mt.
vzAS
mtvz,
mt.
npAS
mtnp,
mt.
massAS
mtmass,
mt.
sizeAS
mtsize,
mt.
spinAS
mtspin,
mt.
ixAS
mtix,
mt.
iyAS
mtiy,
mt.
izAS
mtiz,
mt.
phkeyAS
mtphkey,
f.
ffofIdAS
ffofId,
f.
fsnapnumAS
fsnapnum,
f.
flevelAS
flevel,
f.
fNInFileAS
fNInFile,
f.
fxAS
fx,
f.
fyAS
fy,
f.
fzAS
fz,
f.
fvxAS
fvx,
f.
fvyAS
fvy,
f.
fvzAS
fvz,
f.
fnpAS
fnp,
f.
fmassAS
fmass,
f.
fsizeAS
fsize,
f.
fdispAS
fdisp,
f.
fdisp_vAS
f__disp_v,
f.
fdeltaAS
fdelta,
f.
fspinAS
fspin,
f.
fangMom_xAS
fangMom_x,
f.
f__angMom_yAS
fangMom_y,
f.
fangMom_zAS
f__angMom_z,
f.
fangMomAS
fangMom,
f.
faxis1AS
faxis1,
f.
faxis2AS
faxis2,
f.
faxis3AS
faxis3,
f.
faxis1_xAS
faxis1_x,
f.
f__axis1_yAS
faxis1_y,
f.
faxis1_zAS
f__axis1_z,
f.
faxis2_xAS
faxis2_x,
f.
f__axis2_yAS
faxis2_y,
f.
faxis2_zAS
f__axis2_z,
f.
faxis3_xAS
faxis3_x,
f.
f__axis3_yAS
faxis3_y,
f.
faxis3_zAS
f__axis3_z,
f.
fixAS
fix,
f.
fiyAS
fiy,
f.
fizAS
fiz,
f.
fphkeyAS
fphkey,
f.
rsnapnumAS
rsnapnum,
f.
raexpAS
raexp,
f.
rzredAS
rzredFROM MDR1.FOFMtree AS
mtJOIN ( SELECT
ffofId,
fsnapnum,
flevel,
fNInFile,
fx,
fy,
fz,
fvx,
fvy,
fvz,
fnp,
fmass,
fsize,
fdisp,
fdisp_v,
fdelta,
fspin,
fangMom_x,
f__angMom_y,
fangMom_z,
fangMom,
faxis1,
faxis2,
faxis3,
faxis1_x,
f__axis1_y,
faxis1_z,
faxis2_x,
f__axis2_y,
faxis2_z,
faxis3_x,
f__axis3_y,
faxis3_z,
fix,
fiy,
fiz,
fphkey,``,
rsnapnum,
raexp,
rzredFROM
aggregation_tmp_31621782) AS
fWHERE (
mt.
fofId=
f.
ffofId) AND (
f.
fmass=
mt.
mass) ', 'aggregation_tmp_51077786')-- CALL paquDropTmp('aggregation_tmp_73042841')-- CALL paquDropTmp('aggregation_tmp_31621782')-- USE spider_tmp_shard-- SET @i=0-- CREATE TABLE cosmosim_user_surfcast23.
Join1ENGINE=MyISAM SELECT @i:=@i+1 AS
row_id,
mtfofTreeId,
mtfofId,
mttreeSnapnum,
mtdescendantId,
mtlastProgId,
mtmainLeafId,
mttreeRootId,
mtx,
mty,
mtz,
mtvx,
mtvy,
mtvz,
mtnp,
mtmass,
mtsize,
mtspin,
mtix,
mtiy,
mtiz,
mtphkey,
ffofId,
fsnapnum,
flevel,
fNInFile,
fx,
fy,
fz,
fvx,
fvy,
fvz,
fnp,
fmass,
fsize,
fdisp,
fdisp_v,
fdelta,
fspin,
fangMom_x,
fangMom_y,
f__angMom_z,
fangMom,
faxis1,
faxis2,
faxis3,
faxis1_x,
faxis1_y,
f__axis1_z,
faxis2_x,
faxis2_y,
f__axis2_z,
faxis3_x,
faxis3_y,
f__axis3_z,
fix,
fiy,
fiz,
fphkey,
rsnapnum,
raexp,
rzredFROM
aggregation_tmp_51077786-- CALL paquDropTmp('aggregation_tmp_51077786')