[cc soci-users]
Hello,
Thank you for writing and reporting this. This certainly doesn't sound
right and I'll look into this when I have the chance. It would be really
helpful if you could provide a complete example for both versions (MySQL++
and SOCI), including the SQL code to populate the database. Just so that I
know I'm looking at the same thing as you are. I realize it's some work
but it would really make it much easier for me.
Also, I'm curious which version of SOCI you are using. There was some bad
performance bug in the MySQL backend but it was fixed in 2009 so it's
probably not it?
Thanks,
Aleksander
On Sun, May 20, 2012 at 1:39 PM, Erwin Oegema <[email protected]>wrote:
> Dear Pawel Fedorynski,
>
> My group and I have been working with the SOCI Database Access Library for
> our private server project. The library is easy to use and all, but I’ve
> noticed that it’s way slower than mysql++, which we used before SOCI. This
> slowness is noticable at connection time and gathering rows. Getting the
> server up and running takes 45 seconds with SOCI, while it was only 1 with
> MySQL++!
>
> For example, I’ve pasted our ‘equipment loading code’ below, which does
> nothing else than loading 8285~ rows of data, parsing them and caching them
> from our database:
>
> ---------------------------
>
> void EquipDataProvider::loadEquips() {
> m_equipInfo.clear();
> int32_t itemId;
> EquipInfo equip;
> string flags;
> // Ugly hack to get the integers instead of scientific notation
> // Note: This is MySQL's crappy behavior
> // It displays scientific notation for only very large values, meaning
> it's wildly inconsistent and hard to parse
> // We just use the string and send it to a translation function
> soci::rowset<> rs = (Database::getDataDb().prepare << "SELECT *,
> REPLACE(FORMAT(equip_slots + 0, 0), \",\", \"\") AS equip_slot_flags FROM
> item_equip_data");
>
> for (soci::rowset<>::const_iterator i = rs.begin(); i != rs.end();
> ++i) {
> soci::row const &row = *i;
> equip = EquipInfo();
>
> runFlags(row.get<opt_string>("flags"), [&equip](const string &cmp)
> {
> if (cmp == "wear_trade_block") equip.tradeBlockOnEquip = true;
> });
> runFlags(row.get<opt_string>("req_job"), [&equip](const string
> &cmp) {
> if (cmp == "common") equip.validJobs.push_back(-1);
> else if (cmp == "beginner")
> equip.validJobs.push_back(Jobs::JobTracks::Beginner);
> else if (cmp == "warrior")
> equip.validJobs.push_back(Jobs::JobTracks::Warrior);
> else if (cmp == "magician")
> equip.validJobs.push_back(Jobs::JobTracks::Magician);
> else if (cmp == "bowman")
> equip.validJobs.push_back(Jobs::JobTracks::Bowman);
> else if (cmp == "thief")
> equip.validJobs.push_back(Jobs::JobTracks::Thief);
> else if (cmp == "pirate")
> equip.validJobs.push_back(Jobs::JobTracks::Pirate);
> else if (cmp == "dual_blade")
> equip.validJobs.push_back(Jobs::JobTracks::Thief); // TODO: Make this
> better?
> });
>
> itemId = row.get<int32_t>("itemid");
> equip.attackSpeed = row.get<int8_t>("attack_speed", 0);
> equip.healing = row.get<int8_t>("heal_hp", 0);
> equip.slots = row.get<int8_t>("scroll_slots", 0);
> equip.ihp = row.get<int16_t>("hp", 0);
> equip.imp = row.get<int16_t>("mp", 0);
> equip.reqStr = row.get<int16_t>("req_str", 0);
> equip.reqDex = row.get<int16_t>("req_dex", 0);
> equip.reqInt = row.get<int16_t>("req_int", 0);
> equip.reqLuk = row.get<int16_t>("req_luk", 0);
> equip.reqFame = row.get<int16_t>("req_fame", 0);
> equip.istr = row.get<int16_t>("strength", 0);
> equip.idex = row.get<int16_t>("dexterity", 0);
> equip.iint = row.get<int16_t>("intelligence", 0);
> equip.iluk = row.get<int16_t>("luck", 0);
> equip.ihand = row.get<int16_t>("hands", 0);
> equip.iwatk = row.get<int16_t>("weapon_attack", 0);
> equip.iwdef = row.get<int16_t>("weapon_defense", 0);
> equip.imatk = row.get<int16_t>("magic_attack", 0);
> equip.imdef = row.get<int16_t>("magic_defense", 0);
> equip.iacc = row.get<int16_t>("accuracy", 0);
> equip.iavo = row.get<int16_t>("avoid", 0);
> equip.ijump = row.get<int16_t>("jump", 0);
> equip.ispeed = row.get<int16_t>("speed", 0);
> equip.tamingMob = row.get<uint8_t>("taming_mob", 0);
> equip.iceDamage = row.get<uint8_t>("inc_ice_damage", 100);
> equip.fireDamage = row.get<uint8_t>("inc_fire_damage", 100);
> equip.lightningDamage = row.get<uint8_t>("inc_lightning_damage",
> 100);
> equip.poisonDamage = row.get<uint8_t>("inc_poison_damage", 100);
> equip.elementalDefault = row.get<uint8_t>("elemental_default",
> 100);
> equip.traction = row.get<double>("traction", 0.0f);
> equip.validSlots =
> atoli(row.get<string>("equip_slot_flags").c_str());
>
> m_equipInfo[itemId] = equip;
> }
> }
>
> -----------------
>
> It’s nothing too special, but it still takes around 7 seconds to finish
> loading this [image: Bedroefde emoticon].
>
> I hope to hear from you soon.
> Thanks in advance,
>
> Erwin Oegema
> Vana Developer
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users