IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 17, 2015, 12:55:41 PM (11 years ago)
Author:
eugene
Message:

add index for forced galaxy batches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/forcedgalaxybatch.py

    r39127 r39151  
    7272
    7373    '''
     74    Generate ippObjID and make it an index
     75    '''
     76    def addIppObjID (self, tableName):
     77        sql = "ALTER TABLE " + tableName + " ADD COLUMN ippObjID BIGINT"
     78        self.scratchDb.execute(sql)
     79       
     80        sql = "CREATE INDEX ippObjID_index ON " + tableName + " ( ippObjID ) ";
     81        self.scratchDb.execute(sql)
     82
     83        sql = "UPDATE " + tableName + " set ippObjID = (OBJ_ID + (CAT_ID << 32))"
     84        self.scratchDb.execute(sql)
     85
     86    '''
    7487    Overriden from batch base class to import directly from DVO for forced galaxy shape parameters
    7588    '''
     
    101114            self.logger.infoPair("0 rows for ","cpq table")
    102115            return False
     116
     117        # add ippObjID columns and index them:
     118        self.addIppObjID (cptTableName)
     119        self.addIppObjID (cpqTableName)
     120
    103121        return True
    104122
     
    178196            # sqlLine.group("a." + filter[1] + "GalDecErr",       "b.DEC_ERR")
    179197           
    180             sql = sqlLine.makeEquals("WHERE a.ippObjID = (b.OBJ_ID + (b.CAT_ID << 32)) AND a.galModelType = b.MODEL_TYPE AND b.Photcode = " + str(photcode))
     198            sql = sqlLine.makeEquals("WHERE a.ippObjID = b.ippObjID AND a.galModelType = b.MODEL_TYPE AND b.Photcode = " + str(photcode))
    181199           
    182200            self.logger.debugPair("cpq sql: ", sql)
    183201           
    184202            self.scratchDb.execute(sql)
     203
     204            ## # check on the status as we go:
     205            ## sql = "select count(*) as N, galModelType, nFilter, count(*)*nFilter as S from ForcedGalaxyShape group by galModelType, nFilter"
     206            ## rs = self.scratchDb.executeQuery(sql) 
     207            ##
     208            ## while rs.next():
     209            ##     N = rs.getInt(1)
     210            ##     M = rs.getInt(2)
     211            ##     F = rs.getInt(3)
     212            ##     S = rs.getInt(4)
     213            ##     
     214            ##     print "N: %d, TYPE: %d, nFilter: %d, Sum: %d" % (N, M, F, S)
    185215
    186216    '''
     
    207237
    208238            sqlLine.group("objID",             "EXT_ID")
    209             sqlLine.group("ippObjID",          "OBJ_ID + (CAT_ID << 32)")
     239            sqlLine.group("ippObjID",          "ippObjID")
    210240            sqlLine.group("surveyID",          str(self.surveyID))
    211241            sqlLine.group("randomForcedGalID", "RAND("+str(self.batchID)+")")
     
    215245            sql = sqlLine.makeRaw(") SELECT ", " FROM " + cptTableName)
    216246
    217             print "--- sql: " + sql
     247            # print "--- sql: " + sql
    218248
    219249            self.scratchDb.execute(sql)
Note: See TracChangeset for help on using the changeset viewer.