Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
  • 1.  IBM. EntityFrameworkCore slowness opening connection DB2

    Posted Thu May 08, 2025 10:11 AM

    We are developing with IBM.EntityFrameworkCore and netcore version 7 with imb license to deploy it in aks, however whenever you connect the first time to the database exceeds 30 seconds but if you connect again it takes 1 second, we have done tests and we have evidenced that this happens only when you have inactivity, question this is normal? or what should we do so that the connection to the database db2 is not delayed too much? 

    example code

    public ClienteEntity ObtenerCliente(int id)
    {
        try
        {
            using (var context = new MiDbContext()) // Usa tu clase DbContext
            {
                var entidad = context.ClienteEntities
                                     .AsNoTracking() // Opcional: mejora el rendimiento si no vas a modificar el objeto
                                     .FirstOrDefault(e => e.Id == Id);

                return entidad ?? new ClienteEntity();
            }
        }
        catch (Exception)
        {
            throw;
        }
    }

    Add logs 



    ------------------------------
    Marco Ayala
    ------------------------------


  • 2.  RE: IBM. EntityFrameworkCore slowness opening connection DB2

    Posted Thu May 08, 2025 01:19 PM

    What is platform and version of Db2 you are trying to connect to?

    Is the database activated?



    ------------------------------
    Jan Nelken
    Db2 (LUW) DBA
    Open for job
    Katowice or Krakow
    +48 783 109 863
    ------------------------------



  • 3.  RE: IBM. EntityFrameworkCore slowness opening connection DB2

    Posted Thu May 08, 2025 05:04 PM

    Hello Jan
    thank you very much for your answer the one we are using is IBMDServerType.AS400 and the version IBMDBServerVersion.AS400_07_02



    ------------------------------
    Marco Ayala
    ------------------------------



  • 4.  RE: IBM. EntityFrameworkCore slowness opening connection DB2

    Posted Sat May 10, 2025 05:49 AM

    Sorry - I don't know AS400 enough to advise more - I use Db2 for LUW.

    Toronto Lab motto was Db2 is Db2 is Db2 - there are soe microdifferences though :-)



    ------------------------------
    Jan Nelken
    Db2 (LUW) DBA
    Open for job
    Katowice or Krakow
    +48 783 109 863
    ------------------------------



  • 5.  RE: IBM. EntityFrameworkCore slowness opening connection DB2

    Posted Wed May 14, 2025 12:47 PM

    Hi Jan, 
    By any chance do you think it is something of the AS400 version, because this incident only happens in the first connection to db2, it takes so long that my response SLA must be less than 3 seconds. 



    ------------------------------
    Marco Ayala
    ------------------------------



  • 6.  RE: IBM. EntityFrameworkCore slowness opening connection DB2

    Posted Wed May 14, 2025 02:18 PM

    Marco,

    In REAL (i.e Db2 LUW) this would be clab xyzssical symptom of database not being activated - remedy is to activate database using command db2 activate db xyz (https://www.ibm.com/docs/en/db2/12.1.0?topic=commands-activate-database); in strange world of AS400 I have no clue whether such command exists...



    ------------------------------
    Jan Nelken
    Db2 (LUW) DBA
    Open for job
    Katowice or Krakow
    +48 783 109 863
    ------------------------------