Sqlite_orm: why compile slowly ?

Created on 24 Apr 2020  路  11Comments  路  Source: fnc12/sqlite_orm

hello,i used it in my project,it can run successfully,but it compile slowly,why?
my english is poor,looking forward to your reply,thanks

question

All 11 comments

my code is here,tables have fifty columns,three tables or much.
image

cause of big amount of templates. You can reduce compilation time using technique from faq

OK锛宯ow i have another question,
for (auto &item : storage.iterate())
{ for (auto &item2 : storage.iterate(where(c(&Sector::nodebId) == item.userNodebId)))
{ for (auto &item3 : storage.iterate(where(c(&Cell::sectorId) == item2.id)))
{}}}
it has three for锛宎bout 30K record锛宨t run slowly 锛宧ow to optimize

This question is not about sqlite_orm. This question is about optimizing sqlite3 calls. storage::iterate is optimized already. The reason your code runs slowly is big amount of iterations/records. Probably your code can be simplified and transformed into on query if you have simple logic inside your for body. Please show the whole loop.

this is whole loop,maybe i need simplify my Business Logic锛宼hank for your reply. Emmmm

for (auto &item : storage.iterate<NodeB>())
    {
        // cout << storage.dump(item) << endl;
        // cout << item.id << endl;
        // cout << item.nodebName << endl;
        BaseStationInfo bs_temp;
        bs_temp.BSID = item.id;
        bs_temp.Type = item.nodebType;
        bs_temp.LocationX = item.coordinateX;
        bs_temp.LocationY = item.coordinateY;
        cout<<"bs "<<bsxxx<<endl;
        int index = 0;
        for (auto &item2 : storage.iterate<Sector>(where(c(&Sector::nodebId) == item.userNodebId)))
        {
            bs_temp.Sector[index].BSID = item.id;
            bs_temp.Sector[index].SectorID = item2.id;
            bs_temp.Sector[index].IsActive = item2.isActive == "1";
            bs_temp.Sector[index].ACLR1 = item2.aclr1;
            bs_temp.Sector[index].ACLR2 = item2.aclr2;
            bs_temp.Sector[index].ACS1 = item2.acs1;
            bs_temp.Sector[index].ACS2 = item2.acs2;
            bs_temp.Sector[index].ClutterID = item.id;
            bs_temp.Sector[index].wirelessID = item.id;
            bs_temp.Sector[index].RelayAntHeight = item.id;
            bs_temp.Sector[index].SectorFrequencyPoint = item.id;
            bs_temp.Sector[index].Height = item.id;
            bs_temp.Sector[index].NoiseFigure = item.id;
            int index2 = 0;
            for (auto &item3 : storage.iterate<Cell>(where(c(&Cell::sectorId) == item2.id)))
            {
                bs_temp.Sector[index].Cell[index2].TechnologyType = item.id;
                bs_temp.Sector[index].Cell[index2].CellType = item.id;
                bs_temp.Sector[index].Cell[index2].BroadcastChannelCount = item.id;
                bs_temp.Sector[index].Cell[index2].DownlinkLoad = item.id;
                bs_temp.Sector[index].Cell[index2].Radius = item.id;
                bs_temp.Sector[index].Cell[index2].FreStart = item.id;
                bs_temp.Sector[index].Cell[index2].FreEnd = item.id;
                bs_temp.Sector[index].Cell[index2].CarrierPerCell = item.id;
                bs_temp.Sector[index].Cell[index2].Pc = item.id;
                bs_temp.Sector[index].Cell[index2].EPRE = item.id;
                bs_temp.Sector[index].Cell[index2].MaxTxPower = item.id;
                bs_temp.Sector[index].Cell[index2].AntennaHeight = item.id;
                bs_temp.Sector[index].Cell[index2].AntennaDirection = item.id;
                bs_temp.Sector[index].Cell[index2].AntennaMechanicalDownTilt = item.id;
                strcpy(bs_temp.Sector[index].Cell[index2].PropagationModelName, "hello1");
                strcpy(bs_temp.Sector[index].Cell[index2].AntennaName, "hello2");
                bs_temp.Sector[index].Cell[index2].FiberLoss = item2.fiberLoss;
                bs_temp.Sector[index].Cell[index2].CellID = item.id;
                bs_temp.Sector[index].Cell[index2].PSSID = item.id;
                bs_temp.Sector[index].Cell[index2].SSSID = item.id;
                bs_temp.Sector[index].Cell[index2].RBNum = item.id;
                bs_temp.Sector[index].Cell[index2].CarrierNo = item.id;
                bs_temp.Sector[index].Cell[index2].FrequencyBand = item.id;
                index2++;
            }
            bs_temp.Sector[index].CellNumber = index2;
            index++;
        }
        bs_temp.SectorNumber = index;
        vec_bsdata.push_back(bs_temp);
        bsxxx++;
    }

why do you need vec_bsdata?

image
i need output file,for another software.

looks like you are trying to extract a lot of entries at once and write them into file. This is a very heavy operation. You can increase speed by changing HDD to SSD but there is no way to fix it algorithmically.

my workmate has helped me to solve this problem锛宨t can run completely in 10 seconds.
thanks for your relay again,haha

is the issue actual?

ok i close it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nfarid picture nfarid  路  8Comments

juandent picture juandent  路  6Comments

nuttapongCodium picture nuttapongCodium  路  3Comments

ncoder-1 picture ncoder-1  路  5Comments

meghasemim1999 picture meghasemim1999  路  10Comments