Hello, Sören Meyer-Eppler wrote: > I'm constructing some gigantic (as in several 100MBs) insert > statements. I'd now like to execute them using SOCI. Ideally SOCI > would do as little work as possible and just forward the query to > the database. Unfortunately that is not the case. SOCI copies the > statement (multiple times?) in order to be able to execute it in a > destructor (final_action()).
The actual statement is not copied, as the relevant type is not even copyable. The statement wrapper object (the one you manage in code) is copied, possibly several times, but it is just a thin reference to the actual statement, something very similar to a ref-counted shared pointer. This means that copying this object is very cheap. > Questions: > 1) what's the fastest way to execute such queries using SOCI? Depending on the backend, bulk inserts and prepared statements, in this order, might be a safe choice at least for Oracle. > 2) can I somehow get to the native executeQuery mechanism via the > backends? Yes, you can always obtain the low-level handles to the database client objects. See the get_backend() functions in the session and statement class. > 3) can I control the query lifetime and number of copies SOCI makes? There is no reason to do it, as the statement wrapper is very cheap. You can still do it with explicit syntax, which is based on function calls instead of overloaded operators, see "Core" here: http://soci.sourceforge.net/doc/interfaces.html > I'm using mySQL and PostgreSQL backends in case it matters. Bulk statements and prepared statements should be more or less equivalent in these cases, although I admit that I did not measure it at this level of detail. Regards, -- Maciej Sobczak * www.msobczak.com * www.inspirel.com ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Soci-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/soci-users
