C++: PgDatabase or PgConnection and lifetime of the objects?
От | Carlos Moreno |
---|---|
Тема | C++: PgDatabase or PgConnection and lifetime of the objects? |
Дата | |
Msg-id | 3C49F8DB.1080908@mochima.com обсуждение исходный текст |
Ответ на | Re: No history in psql (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: C++: PgDatabase or PgConnection and lifetime of the objects?
|
Список | pgsql-interfaces |
Hi, I'm still not sure I've grasped what are (if any) the important differences between the classes PgDatabase and PgConnection -- some of the descriptions in the docs are identical for both classes, so I'm never sure when to use each (I kind of use PgDatabase by default, but maybe I'm missing something?) Also, I'm quite unsure about what should be the lifetime of the objects: should I create one database object when the application starts, and every time I need to execute an SQL statement, I call Exec? Or should I create a local database object whenever I need it? Normally, I would tend to think that one only object introduces minimum overhead... But then, I'm not sure if there are other factors to consider. My situation is more or less like this: I have a real-time system (not multi-threaded, though) which is the server in a multi-player online game. I'm going to use PostgreSQL for the database, which includes tables for the players (and their passwords and related data), and also for the games, chats, and plays. So, every time a player connects, I'll have to check the database of players to validate their logins (this might happen with a frequency of, say, a couple of times per second). When they're playing, everything will be added to the corresponding tables... This might happen with much higher frequency, I guess several hundred times per second, but the data to store in the database is not much (just a couple of bytes). What approach could you recommend concerning the two details mentioned in the subject? BTW, the above figures are (very rough) estimated peaks; of course, a sustained rate like that would fill up the hard disk in a couple of days :-) Thanks for any thoughts! Carlos --
В списке pgsql-interfaces по дате отправления: