mysql – Consulta SQL tarda mucho tiempo en laravel y en phpmyadmin muy poco

Tengo una consulta que involucra 6 tablas, en laravel tarda 26 segundos en mostrar el resultado y en phpmyadmin 0.0089 segundos.

Foto de phpmyadmin

Resultado en laravel

Este es el código en laravel:

use DB;    
$partidas = DB::select("SELECT A.Patente, A.Pedimento, A.SeccionAduanera, A.Fraccion, A.SecuenciaFraccion, A.ValorComercial, A.PrecioUnitario, A.CantidadUMComercial, A.UnidadMedidaComercial, A.CantidadUMTarifa, A.UnidadMedidaTarifa, A.MetodoValorizacion, A.PaisOrigenDestino, A.PaisCompradorVendedor,  
                                                B.ClavePermiso, B.NumeroPermiso, 
                                                C.ClaveCaso, C.IdentificadorCaso, C.ComplementoCaso, 
                                                D.ClaveContribucion, D.FormaPago, D.ImportePago, 
                                                E.TasaContribucion, E.TipoTasa, 
                                                F.Observaciones
                                        FROM `551` A
                                        INNER JOIN `553` B ON B.Fraccion = A.Fraccion
                                                AND (A.SecuenciaFraccion = B.SecuenciaFraccion)
                                                AND (A.auditoria_id = 4 AND B.auditoria_id = 4)
                                                AND (A.Patente = '3452' AND B.Patente = '3452')
                                                AND (A.Pedimento = '0000180' AND B.Pedimento = '0000180') 
                                                AND (A.SeccionAduanera = '430' AND B.SeccionAduanera = '430')
                                        INNER JOIN `554` C ON C.Fraccion = A.Fraccion 
                                                AND (A.SecuenciaFraccion = C.SecuenciaFraccion)
                                                AND (A.auditoria_id = 4 AND C.auditoria_id = 4)
                                                AND (A.Patente = '3452' AND C.Patente = '3452')
                                                AND (A.Pedimento = '0000180' AND C.Pedimento = '0000180') 
                                                AND (A.SeccionAduanera = '430' AND C.SeccionAduanera = '430')
                                        INNER JOIN `557` D ON D.Fraccion = A.Fraccion 
                                                AND (A.SecuenciaFraccion = D.SecuenciaFraccion)
                                                AND (A.auditoria_id = 4 AND D.auditoria_id = 4)
                                                AND (A.Patente = '3452' AND D.Patente = '3452')
                                                AND (A.Pedimento = '0000180' AND D.Pedimento = '0000180') 
                                                AND (A.SeccionAduanera = '430' AND D.SeccionAduanera = '430')
                                        INNER JOIN `556` E ON E.Fraccion = A.Fraccion 
                                                AND (A.SecuenciaFraccion = E.SecuenciaFraccion)
                                                AND (A.auditoria_id = 4 AND E.auditoria_id = 4)
                                                AND (A.Patente = '3452' AND E.Patente = '3452')
                                                AND (A.Pedimento = '0000180' AND E.Pedimento = '0000180') 
                                                AND (A.SeccionAduanera = '430' AND E.SeccionAduanera = '430')
                                        INNER JOIN `558` F ON F.Fraccion = A.Fraccion 
                                                AND (A.SecuenciaFraccion = F.SecuenciaFraccion)
                                                AND (A.auditoria_id = 4 AND F.auditoria_id = 4)
                                                AND (A.Patente = '3452' AND F.Patente = '3452')
                                                AND (A.Pedimento = '0000180' AND F.Pedimento = '0000180') 
                                                AND (A.SeccionAduanera = '430' AND F.SeccionAduanera = '430')
                                        ");
                dd($partidas);

Por el momento tengo los valores estáticos para hacer pruebas pero serán con variables.

¿Sabrán por qué tarda tanto? y/o si es mejor hacer la consulta de otra forma para obtener más rendimiento.

Gracias!!

What are the features and price of Poco X2?

Features of Poco X2 filtered, check price and expected features

pocof1 – How to make Gcam work in POCO F1

The best resource for all Gcam links for POCO F1 is available on the XDA forums listed at https://www.celsoazevedo.com

Be sure to read and follow the instructions correctly before downloading and installing it on your Android device.

When choosing the APK to download, make sure your version of the Android operating system is compatible with the version of the APK that will be installed.

c # – Change POCO tracking entities

Description

In an era where thin clients, web browsers, web services and microservices prevail, we tend to forget that we still have to deal with thick and intelligent customers. Many applications in B2B still use the latter. It is common in such clients that the user can perform a set of actions on the client before synchronizing it with the server.

One of these scenarios is a master detail view where the user can Edit, cancel Y Apply Changes in the teacher. In editing, a detailed view is activated where the user can to accept or cancel the changes for that particular edition. Each time the user accepts changes, they are considered the last state of the entity. In an upcoming edition, when canceled, the status returns to the last accepted state. Only when the master view is applied, all changes are sent to the server. When the master view is canceled, all detail changes are also reverted to the initial state.

API

Microsoft had a solution for this: automatic tracking entities. But that API is no longer supported. Although there are other APIs available and / or under development, I wanted to try to write a low-level API as suggested by Microsoft:
… or write custom code using the low level change tracking APIs. I am not sure I want to maintain or extend this API. Probably first check if the current version survives the Code Review.

Current features:

  • accept / reject changes to a complex object
  • can cross object trees and cyclic graphics (hierarchical change tracking)
  • contextless change tracking that works in POCO
  • tracking of a detail entity while the teacher also performs independent monitoring (tracking of compound changes)
  • stack change trackers in a single entity (multi-level change tracking)

Currently out of reach:

  • item tracking in collections
  • allowing not to track navigation properties

Questions

  • Does it make sense to make a custom API or should I use an existing one?
  • Is the API extensible, usable and maintainable?
  • Am I adhering to code conventions and best practices?

Code

The main object tracker for a consumer ObjectEditor allows multi-level object tracker through implementation IEditableObject. BeginEdit Start an atomic update session. EndEdit accept the current update while CancelEdit go back to the last EndEdit or initial state. RejectChanges returns to the initial state, regardless of the number of edits made, and AcceptChanges Accept all current editions.

public sealed class ObjectEditor : IRevertibleChangeTracking, IEditableObject
{
    private readonly Stack trackers = new Stack();
    public bool IsChanged { get; private set; }
    public object Source { get; }

    public ObjectEditor(object source) => Source = source ?? throw new ArgumentNullException(nameof(source));

    public void AcceptChanges() => UntilEmpty(() => EndEdit());

    public void RejectChanges() => UntilEmpty(() => CancelEdit());

    public void BeginEdit() => trackers.Push(new ComplexObjectTracker(Source));

    public void CancelEdit() => Pop(tracker => tracker.RejectChanges());

    public void EndEdit() => Pop(tracker => tracker.AcceptChanges());

    private void UntilEmpty(Action operation)
    {
        while (trackers.Any()) operation?.Invoke();
    }

    private void Pop(Action operation)
    {
        if (!trackers.Any()) return;
        var tracker = trackers.Pop();
        operation?.Invoke(tracker);
    }
}

Internally, instances of ComplexObjectTracker they are used to track entities, their properties and recursively track the entire graph of the object.

public class ComplexObjectTracker : IRevertibleChangeTracking
{
    public bool IsChanged { get; private set; }
    public object Source { get; }
    List Visited { get; }
    List PropertyTrackers { get; }

    public ComplexObjectTracker(object source, List visited = null)
    {
        Source = source ?? throw new ArgumentNullException(nameof(source));
        Visited = visited ?? new List();
        IsChanged = true;

        PropertyTrackers = (from p
              in source.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
                            where !p.GetIndexParameters().Any()
                            select p).Select(p => CreateChangeTracker(p)).ToList();
    }

    public void AcceptChanges() => Invoke(p => p.AcceptChanges());

    public void RejectChanges() => Invoke(p => p.RejectChanges());

    private void Invoke(Action operation)
    {
        PropertyTrackers.ForEach(operation);
        IsChanged = false;
    }

    private IRevertibleChangeTracking CreateChangeTracker(PropertyInfo property)
    {
        if (property.PropertyType.IsValueType)
        {
            return new PropertyReferenceTracker(Source, property);
        }

        return new DeepPropertyTracker(Source, property, Visited);
    }
}

As you can see, currently only two types of property tracking are implemented: PropertyReferenceTracker Y DeepPropertyTracker. In future versions, additional trackers could be provided to track collections (shallow, deep, with orders or not, etc.).

public class PropertyReferenceTracker : IRevertibleChangeTracking
{
    public bool IsChanged { get; private set; }
    public object DeclaringInstance { get; }
    public object PropertyValue { get; }
    public PropertyInfo Property { get; }

    public PropertyReferenceTracker(object declaringInstance, PropertyInfo property)
    {
        DeclaringInstance = declaringInstance ?? throw new ArgumentNullException(nameof(declaringInstance));
        Property = property ?? throw new ArgumentNullException(nameof(property));
        PropertyValue = Property.GetValue(DeclaringInstance);
        IsChanged = true;
    }

    public virtual void AcceptChanges() => IsChanged = false;

    public virtual void RejectChanges()
    {
        if (Property.CanWrite)
        {
            Property.SetValue(DeclaringInstance, PropertyValue);
        }
        IsChanged = false;
    }
}

public class DeepPropertyTracker : PropertyReferenceTracker
{
    public IRevertibleChangeTracking deepTracker { get; }

    public DeepPropertyTracker(object declaringInstance, PropertyInfo property, List visited)
        : base(declaringInstance, property)
    {
        deepTracker = PropertyValue != null && !visited.Contains(PropertyValue) ? new ComplexObjectTracker(PropertyValue, visited) : null;
    }

    public override void AcceptChanges()
    {
        deepTracker?.AcceptChanges();
        base.AcceptChanges();
    }

    public override void RejectChanges()
    {
        deepTracker?.RejectChanges();
        base.RejectChanges();
    }
}

Usage scenario

I did a little demonstration using a trivial LITTLE Employee to show current features. As you can see, there is a graph of an infinite potential depth of the object. This should show how object graphics are handled.

class Employee
{
    public DateTime BirthDate { get; set; }
    public string FirstName { get; set; }
    public string Name { get; set; }
    public Employee Manager { get; set; }
}

And some unit tests to verify the behavior of change tracking.

(TestClass)
public class Fixtures
{
    private Employee employee;

    (TestInitialize)
    public void TestInit()
    {
        var manager = new Employee
        {
            BirthDate = new DateTime(1980, 1, 1),
            FirstName = "John",
            Name = "Doe"
        };

        employee = new Employee
        {
            BirthDate = new DateTime(2000, 1, 1),
            FirstName = "Rembrandth",
            Name = "Smith",
            Manager = manager
        };
    }

    (TestMethod)
    public void EndEdit()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Name, "Smith");

        employee.Name = "X";
        editor.EndEdit();
        Assert.AreEqual(employee.Name, "X");
    }

    (TestMethod)
    public void CancelEdit()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Name, "Smith");

        employee.Name = "X";
        editor.CancelEdit();
        Assert.AreEqual(employee.Name, "Smith");
    }

    (TestMethod)
    public void EndHierarchicalEdit()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");

        employee.Manager.Name = "X";
        editor.EndEdit();
        Assert.AreEqual(employee.Manager.Name, "X");
    }

    (TestMethod)
    public void EndHierarchicalEdit_OtherRef()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");

        employee.Manager = new Employee
        {
            BirthDate = new DateTime(1789, 1, 1),
            FirstName = "Juan",
            Name = "Carlos"
        };
        editor.EndEdit();
        Assert.AreEqual(employee.Manager.Name, "Carlos");
    }

    (TestMethod)
    public void CancelHierarchicalEdit_OtherRef()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");

        employee.Manager = new Employee
        {
            BirthDate = new DateTime(1789, 1, 1),
            FirstName = "Juan",
            Name = "Carlos"
        };
        editor.CancelEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");
    }

    (TestMethod)
    public void CancelHierarchicalEdit()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");

        employee.Manager.Name = "X";
        editor.CancelEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");
    }

    (TestMethod)
    public void EndCompositeEdit()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");

        employee.Manager.Name = "X";

        {
            var compositeEditor = new ObjectEditor(employee.Manager);
            compositeEditor.BeginEdit();

            Assert.AreEqual(employee.Manager.Name, "X");

            employee.Manager.Name = "Y";

            compositeEditor.EndEdit();
            Assert.AreEqual(employee.Manager.Name, "Y");
        }

        editor.EndEdit();
        Assert.AreEqual(employee.Manager.Name, "Y");
    }

    (TestMethod)
    public void CancelCompositeEdit()
    {
        var editor = new ObjectEditor(employee);
        editor.BeginEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");

        employee.Manager.Name = "X";

        {
            var compositeEditor = new ObjectEditor(employee.Manager);
            compositeEditor.BeginEdit();

            Assert.AreEqual(employee.Manager.Name, "X");

            employee.Manager.Name = "Y";

            compositeEditor.EndEdit();
            Assert.AreEqual(employee.Manager.Name, "Y");
        }

        editor.CancelEdit();
        Assert.AreEqual(employee.Manager.Name, "Doe");
    }
}

c # – Split data logic and domain logic in POCO class?

Let's say, for example, in this simulated bank ATM application solution, I have 3 projects:

  • UI console
  • Domain Model (POCO)
  • Persistence (Entity Framework for CRUD)

Domain Model (POCO): I have 2 classes

public class BankAccount
{
    public int Id { get; set; }
    public string AccountName { get; set; }
    public decimal Balance { get; set; }

    public decimal CheckBalance()
    {
        return Balance;
    }

    public void Deposit(int amount)
    {
        // Domain logic
        Balance += amount;

        // Add transaction
        var transaction = new Transaction()
        {
            Id = 1,
            TransactionDateTime = DateTime.Now,
            Amount = amount,
            TransactionType = TransactionType.Deposit
        };

        // Save changes into DB via EF. Data Logic should be here? Then where?
    }

    public void Withdraw(int amount)
    {
        // Domain logic
        Balance -= amount;

        var transaction = new Transaction()
        {
            Id = 2,
            TransactionDateTime = DateTime.Now,
            Amount = amount,
            TransactionType = TransactionType.Withdraw
        };

        // Save changes into DB via EF. Data Logic should be here? Then where?

    }
}

public class Transaction
{
    public int Id { get; set; }
    public DateTime TransactionDateTime { get; set; }
    public TransactionType TransactionType { get; set; }
    public int Amount { get; set; }
}

public enum TransactionType
{
    Deposit, Withdraw
}

Console UI

class Program
{
    static void Main(string() args)
    {
        var bankAccount = new BankAccount() { Id = 1, AccountName = "John", Balance = 250M };

        Console.WriteLine("1. Check balance");
        Console.WriteLine("2. Deposit");
        Console.WriteLine("3. Withdraw");
        Console.WriteLine("Enter option: ");
        string opt = Console.ReadLine();
        switch (opt)
        {
            case "1":
                Console.WriteLine($"Your balance is ${bankAccount.CheckBalance()}");
                break;
            case "2":
                bankAccount.Deposit(50);
                Console.WriteLine("Deposit successfully");
                break;
            case "3":
                bankAccount.Withdraw(20);
                Console.WriteLine("Withdraw successfully");
                break;
            default:
                break;
        }

    }
}

I have some questions here.

  1. If a pure method involves doing only one thing, does my deposit method violate this principle? If so, how should it be then?
  2. In the POCO class, I have domain logic as a comment. But I shouldn't have my data logic (CRUD operation) there right? So where should I put the data logic? For example, db.SaveChanges (for Entity Framework).

How to use the environment variable in Poco: "Path" property of FileChannel

I am using the Poco :: LoggingConfigurator library for the registry, using Poco :: XMLConfiguration to configure the registry properties. I want to use an environment variable in the path value of the registry configuration xml file. How to do it in the xml configuration file?

This is the xml configuration file that I am using now.



  
    FileChannel
    /logs/agent-xfs.log
    1 M
    timestamp
    true
    60
  



  
    logFileChannel
    debug
  

I want to define the value of the route variable using the environment variable as follows,

$ {ENV_SAMPLE_VARAIBLE} /logs/sample.log

What you need to know about POCO CRM – Everything else

It's easy to get images of the benefits when your crm software online You can book moving orders. Little CRM software is designed to help companies manage their sales force and daily activities. It helps you track the sales funnel, accounts, contacts, leads and opportunities. POCO CRM is highly successful for companies in Projects, Direct Sales and Channel Sales. POCO CRM helps them track and monitor the performance of their sales team.

Provided with the mobile application, it helps the sales force to update their daily activities while they are on the move. Little crm is not 1 name in sales sales.

Get full visibility of your sales cycle. Align sales efforts with your business strategies and goals. For more information, visit our website http://www.pococrm.com

Blog source- https://myttechnoblog.blogspot.com/2019/01/about-poco-crm.html