Domanda

I have FirebirdSql dll Version 4.1 in my .NET project, which is connected to a Firebird Sql server Version 2.1 and I test my sql-scripts using FlameRobin client (very handy tool).

Anyway, the problem I´m facing is that every script I execute in FlameRobin is very fast but when running the same script through FirebirdSql in my .NET project it takes much longer. Maybe there is no easy answer to this, has anyone got any idea why this would work so slowly within my C# project?

This is the sql-script I execute within Flamerobin, it takes a split second to execute:

SELECT t.S_ID, t.TR_SEQ, t.TR_DATE, t.TR_TIME, t.TR_TERM_SLA, r.DR_NAME, t.TR_DPT_NO, t.TR_EVENT, ev.ET_DESC, t.TR_DIRECTION, t.TR_TAG_CODE, m.MST_FIRST_NAME, m.MST_LAST_NAME, t.TR_TT_TYPENO, t.TR_MSTSQ, t.TR_REASON_CODE, t.TR_PROCESSED
from TRANSACK t left outer join MASTER m on t.TR_MSTSQ = m.MST_SQ, EVENT_TYPE ev, READER r
where ev.ET_TYPENO = t.TR_EVENT and r.T_ADDR = t.TR_TERM_SLA and 20140205 <= t.TR_DATE and 20140206 >= t.TR_DATE and (m.MST_LAST_NAME like '%' or m.MST_LAST_NAME is null) and (m.MST_FIRST_NAME like '%' or m.MST_FIRST_NAME is null) and t.TR_TAG_CODE like '%'
order by t.TR_DATE desc, t.TR_SEQ desc

This is the same script within my C# project, it takes just over 10 seconds to execute:

_firebirdContext.OpenConnection();
List<Transaction> stuffFromTransactions = new List<Transaction>();

FbCommand readTransaction = new FbCommand("SELECT t.S_ID, t.TR_SEQ, t.TR_DATE, t.TR_TIME, t.TR_TERM_SLA, r.DR_NAME, t.TR_DPT_NO, t.TR_EVENT, ev.ET_DESC, " + 
    "t.TR_DIRECTION, t.TR_TAG_CODE, m.MST_FIRST_NAME, m.MST_LAST_NAME, t.TR_TT_TYPENO, t.TR_MSTSQ, t.TR_REASON_CODE, t.TR_PROCESSED " +
    "from TRANSACK t left outer join MASTER m on t.TR_MSTSQ = m.MST_SQ, EVENT_TYPE ev, READER r " + 
    "where ev.ET_TYPENO = t.TR_EVENT and r.T_ADDR = t.TR_TERM_SLA and 20140205 <= t.TR_DATE and 20140206 >= t.TR_DATE and (m.MST_LAST_NAME like '%' or m.MST_LAST_NAME is null) and (m.MST_FIRST_NAME like '%' or m.MST_FIRST_NAME is null) and t.TR_TAG_CODE like '%'" +         
    "order by t.TR_DATE desc, t.TR_SEQ desc", _firebirdContext.FbConnection);
FbDataReader transactionReader = readTransaction.ExecuteReader();
while (transactionReader.Read())
{
    Transaction transaction = new Transaction();
    if (!Convert.IsDBNull(transactionReader[0]))
    {
        transaction.S_ID = (int)transactionReader[0];
    }
    if (!Convert.IsDBNull(transactionReader[1]))
    {
        transaction.TR_SEQ = (int)transactionReader[1];
    }

    // ...
    // abbreviated
    // ...

    if (!Convert.IsDBNull(transactionReader[16]))
    {
        transaction.TR_PROCESSED = (Int16)transactionReader[16];
    }
    stuffFromTransactions.Add(transaction);
}
transactionReader.Close();
_firebirdContext.CloseConnection();
return stuffFromTransactions;
È stato utile?

Soluzione

Likely you're not fetching all records in FlameRobin, just viewing first x in the grid.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top