While using ANTS Performance Profiler (v 10.1.3.1233) to track down some performance issues, I noticed that the profiler indicates that some database calls are being performed twice. I cannot see the duplicate database calls directly, but I am confident they are actually occurring twice, and not merely being reported twice, since the elapsed times per duplicate calls, while very close, are not exactly the same.
Below is a sample console app that demonstrates performing a simple select statement two different ways.
Code: Select all
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Devart.Data.PostgreSql;
namespace CGMUSLAB_13142
{
class Program
{
static void Main(string[] args)
{
string pw = Console.ReadLine();
string connectionString = $@"User Id=exp_load_191;Password={pw};Host=D-LAB-TESTSVR2.CGMUS.LOCAL;Port=5432;Database=cgmlab;Unicode=True;Connection Timeout=0;Pooling=True;Max Pool Size=100";
var connection = new PgSqlConnection(connectionString);
connection.Open();
string sql = "select * from organization_detail";
using (var table1 = new DataTable())
{
LoadATable(connection, sql, table1);
}
using (var table2 = new DataTable())
{
LoadBTable(connection, sql, table2);
}
}
private static void LoadATable(PgSqlConnection connection, string sql, DataTable dataTable)
{
using (var dataAdapter = new PgSqlDataAdapter(sql, connection))
{
dataAdapter.Fill(dataTable);
}
}
private static void LoadBTable(PgSqlConnection connection, string sql, DataTable dataTable)
{
using (var command = new PgSqlCommand(sql, connection))
{
using (var olReader = command.ExecuteReader())
{
dataTable.Load(olReader);
}
}
}
}
}
Can you tell me if my use of the ExecuteReader method has an error that causes PostGreSQL to read the data twice?
Or is this a bug in Dot Connect for PostGreSQL?
Thanks for your assistance.
Bill.