I would like to understand what OLTP is

2

They asked me this question: What is OLTP? I ran home, opened google and started to "goolgar", so I came across these codes, which are said to have problems in OLTP environments and I do not understand bullying:

public JsonResult ListarAlocacoes(AlocacaoView alocacaoView)
{
    var contratosAlocacaoList = ObterContratosAlocacao(alocacaoView);

    /* ... */
}

private IList<AlocacaoJson> ObterContratosAlocacao(AlocacaoView alocacaoView = null)
{
    var contratoList = BaseContext.DbContext.Set<Contrato>().Include("ContratoValores").ToList();

    foreach (var contrato in contratoList.Where( /* ... */ ))
    {
        var alocacao = MontarAlocacao(contrato, alocacaoView.CompetenciaId);

        /* ... */
    }

    /* ... */
}

private AlocacaoJson MontarAlocacao(Contrato contrato, DateTime dataCompetencia, int? equipeId = null)
{
    var alocacao = new AlocacaoJson();

    /* ... */

    alocacao.Equipe = ObterEquipeContrato(contrato, equipeId);
    alocacao.CustoTotal = ObterCustoTotalContrato(contrato, dataCompetencia);

    /* ... */
}

private EquipeJson ObterEquipeContrato(Contrato contrato, int? equipeId)
{
    var equipe = BaseContext.DbContext.Set<Equipe>().Find(equipeId.Value);

    /* ... */
}

private CustoTotalJson ObterCustoTotalContrato(Contrato contrato, DateTime dataCompetencia)
{
    var competencia = BaseContext.DbContext.Set<Competencia>().Where(c => c.Data == dataCompetencia).First(); ;
    var alocacao = BaseContext.DbContext.Set<Alocacao>().Include("AlocacoesProjeto").Include("Contrato").Include("Equipe").SingleOrDefault(c => c.CompetenciaData == competencia.Data);

    var valorHora = BaseContext.DbContext.Set<Funcao>().Find( /* ... */ ).ValoresHoras.SingleOrDefault( /* ... */ );

    var custoTotal = (decimal)(valorHora.Valor * alocacao.QtdeHoras) /* ... */;

    /* ... */
}

In a production environment would this stick to an OLTP approach? Why?

    
asked by anonymous 08.03.2018 / 18:32

1 answer

4

There are basically two database access / data processing models, the OLTP (OnLine Transaction Processing) and or OLAP (OnLine Analytical Processing).

OLTP is what almost everyone does, logs, changes, changes some specific point of a data, removes, calculates, retrieves to view or access directly, does some batch processing to change the data in general. It's the data of the day.

OLAP is used in data analysis, usually a large volume and together. The data does not usually have to be the most current, it is common to take what was generated in OLTP and copied to work with OALP. It is common for OLAP to generate new data based on what came from OLTP. It can come from multiple sources, not necessarily a database. This is called Data Warehouse .

Any code can have problems in OLTP or OLAP if it is not done well. Just looking at the code does not tell. Who said that, why? Did you mention what situation? How much data? What is the level of effective competition? Did you show other relevant points of the code and general structure?

If you do not have any of this the information is not reliable. Always remember that there are a lot of people writing things on the internet, and most of them are wrong, incomplete, inaccurate or biased.

It may be the lack of the correct transaction, but I do not know, when it has too much abstraction it becomes more complicated to say. It's possible. But do you need this transaction? It is possible.

There are even several myths about the subject in articles until they seem reliable. But this is another matter.

    
08.03.2018 / 23:41