0

I'm using SqlServer as logging. Yes this is wrong decision, there are better dbs for this requirement. But I have no other option for now.

Logging interval is 3 logs per second.

So I've static Logger class and it has static Log method.

Using "Open Connection" as static member is better for performance. But what is the best implemantation of it?

This is not that I know.

public static class OzzLogger
{
    static SqlConnection Con;

    static OzzLogger()
    {
       Con=ne SqlConnection(....);
       Con.Open();  
    }

    public static void Log(....)
    {
       Con.ExecuteSql(......);
    }
}

UPDATE

I asked because of my old information. People say "connection pooling performance is enough". If there is no objection I'm closing the issue :)

Oguz Karadenizli
  • 3,449
  • 6
  • 38
  • 73
  • Where do you get the idea that you'll get better performance that way? – Andrew Barber Sep 06 '12 at 20:52
  • 1
    Agree. SQL Server and .net use connection pooling and all that is managed for you. Your static connection could actually block a simultaneous command. – FlavorScape Sep 06 '12 at 20:56
  • `Yes this is wrong decision, there are better dbs for this requirement.` If you worry about insert performance, may be you can write your log sequential to a file with log rotation and perform your insert as a batch to SQL Server. – edze Sep 06 '12 at 21:28
  • Hmm.. I have old information about that. Maybe connection pooling was not as good as it is today. – Oguz Karadenizli Sep 06 '12 at 21:31
  • @edze I mean Cassandra as better logging database.. – Oguz Karadenizli Sep 06 '12 at 21:33
  • 1
    @ozz Sounds like you got *bad* information, not *old*. The Microsoft providers involved here have always done a pretty good job of connection pooling. You certainly should not be trying to circumvent it. But yes; a different DBMS *might* be a good option, too. (although, 3/sec is hardly a high volume, and if you are using SQL Server otherwise, it seems like a no-brainer to keep it. – Andrew Barber Sep 06 '12 at 21:39
  • 1
    Cassandra is not implicitly better. It alway depend on your data stucture and size and also how much distributed nodes you need to do your distributed jobs/tasks. I think `CAP theorem` is the keyword in this case. http://stackoverflow.com/questions/2794736/best-data-store-for-billions-of-rows – edze Sep 06 '12 at 21:40

0 Answers0