Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4083562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:19:43+00:00 2026-05-20T18:19:43+00:00

In my symfony project, I have a complex query that looks like: $d =

  • 0

In my symfony project, I have a “complex” query that looks like:

$d = Doctrine_Core::getTable('MAIN_TABLE')
    // Create the base query with some keywords
->luceneSearch($keywords)
->innerJoin('w.T1 ws')
->innerJoin('ws.T2 s')
    ->innerJoin('w.T3 piv')
->innerJoin('piv.T4 per')
->innerJoin('w.T5 st')
    ...
->innerJoin('doc.T12 docT')
->innerJoin('w.Lang lng')
->execute();

I added all those innerJoin to reduce the number of query due to my data model. Actually all data are recovered with this only query…. but the query took from 2 to 20 sec. depends on keywords.

I decided to use memcache because data are not changing all the time.

What I’ve done is configuring memcache and adding

...
->useResultCache(true)
->execute();

to my query.

What is strange is that :

  • The first time (when the cache is empty/flushed), only one query is execute
  • The second time, ~130 ares executed and it take more time than the first…

Those “new” queries are retrieving data from “inner join” for each record.

What I don’t undestand is why “innerjoined” data are not saved in the cache?

I tried to change the hydrate mode but it seems not to be influent.

Someone has an idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:19:43+00:00Added an answer on May 20, 2026 at 6:19 pm

    After a whole day to googlise, to analyse doctrine and become desperate, I found an article that explain the solution:

    class User extends BaseUser{
        public function serializeReferences($bool=null)
        {
            return true;
        }
    }
    

    The problem was the profile object was not getting stored in the result cache and thus causing a query each time it was called from the user object. After much hunting around, a long time in #doctrine, and a few leads from a couple of people, it turns out, by default, Doctrine will only serialize the immediate relation to the main object. However, you can make it so that it will serialize objects further down the line by overriding the function serializeReferences to return true in the class you want to serialize references from. In my example this is the User class. Since our application will never only need the ‘User’ class to be serialized on a result cache I completely overrode the function and made it always return true

    http://shout.setfive.com/2010/04/28/using-doctrine-result-cache-with-two-deep-relations/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a symfony project. There is a website and a rest API that
i am using Symfony 1.4, to create my project. i have tried to deploy
I'm looking for something like break for loops. Here's some example code (using Symfony's
I have a Symfony project on a Win XP / IIS 7 machine with
I am building a Symfony project, and have created a new plug-in named sfUtilsPlugin
I'm working on a Symfony project (my first) where I have to retrieve, from
I am working on a Symfony project and I currently have this: <?php echo
I have been trying to upload my SYmfony plugin for some time but I
I have an sf1.2 based project that works in the local deployment. I deployed
I have a symfony project where I have a module called ImportBundle. For rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.