Coder Social home page Coder Social logo

Comments (5)

jonspalmer avatar jonspalmer commented on July 4, 2024

From by brief research I believe its common for STI libraries to behave like this.

a) I'd be curious to see numbers of the relative performance of the queries
b) we'd need this behavior to be configurable so we can support situations where there are unmapped types in the type column that shouldn't be returned by a root query.

I don't have time to dig in to the implementation details of this but a PR would always be considered.

from single-table-inheritance.

darron1217 avatar darron1217 commented on July 4, 2024

@jonspalmer Thanks for the reply.

a) When it comes to about 10000 records, it matters. I brought evidence from laravel repo.
image
laravel/framework#26051 (comment)

b) yes, i agree to your opinion.

I will create PR for this issue soon :)

from single-table-inheritance.

jonspalmer avatar jonspalmer commented on July 4, 2024

@darron1217 thanks for the details but those are not good examples of the problem.

a) The first query is only selecting one column from the table which will typically be faster than selecting "*" as there is less data to for the DB to collect and send over the wire
b) A very large "IN" query with 1000s of values in the "in' condition is potentially slow (to send as a query and to execute). However, we're talking about a max # of conditions as the max of the number of classes you have mapped.
c) The indexing performance will be very different. A type column for STI will have low cardinality (the # of mapped classes) vs a Primary Key index in those examples which will necessarily be unique. The query performance of queries against those two types of indexes will be very different. It also might be that certain SQL engines optimize the "where in" query to a no-op if you pass every value of the index 😄.

We think we need real examples of the problem at hand with sql "EXPLAIN" details of the queries.

from single-table-inheritance.

darron1217 avatar darron1217 commented on July 4, 2024

@jonspalmer
Oh, I didn't realize that I brought wrong example... haha

I'll test with index as you mentioned :)

from single-table-inheritance.

darron1217 avatar darron1217 commented on July 4, 2024

@jonspalmer
I just tested on my database, and only 1 milisecond delayed....

Let's close this issue :)

from single-table-inheritance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.