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 7853279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:38:16+00:00 2026-06-02T19:38:16+00:00

I have managed to write the below query, which works great. My problem is

  • 0

I have managed to write the below query, which works great. My problem is that I am using it a bunch of times and I think it warrants its own view, but when I have phpmyadmin create the view for me, queries that used to take 0.0060 sec now take 6.2094 sec.

My Query:

SELECT tr.uuid, tr.creator,
(
    SELECT
    GROUP_CONCAT(name)
    FROM tags as t1
    WHERE t1.uuid = tr.uuid and t1.type = "name"
    GROUP BY t1.uuid
) as names,
(
    SELECT GROUP_CONCAT(name)
    FROM tags as t2
    WHERE t2.uuid = tr.uuid and t2.type = "tag"
    GROUP BY t2.uuid
) as tags

FROM `tags` as tr

phpMyAdmin’s Conversion:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` 
SQL SECURITY DEFINER 
VIEW `textagname` AS 
select 
`tr`.`uuid` AS `uuid`,
`tr`.`creator` AS `creator`,
(
    select group_concat(`t1`.`name` separator ',') AS `GROUP_CONCAT(name)` 
    from `tags` `t1` 
    where ((`t1`.`uuid` = `tr`.`uuid`) and (`t1`.`type` = 'name')) 
    group by `t1`.`uuid`
) AS `names`,
(
    select group_concat(`t2`.`name` separator ',') AS `GROUP_CONCAT(name)`
    from `tags` `t2` 
    where ((`t2`.`uuid` = `tr`.`uuid`) and (`t2`.`type` = 'tag')) 
    group by `t2`.`uuid`
) AS `tags` 
from `tags` `tr`

Any ideas as to how I can make my view more time efficient?

ps: Here is the tags table structure:

Column   Type         Null  Default  Comments
-------  -----------  ----  -------  ------------------
uuid     varchar(36)  No             key of texture
name     varchar(64)  No             tag name
creator  varchar(36)  Yes   NULL     creator of the tag
type     varchar(36)  No             name, or tag
  • 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-06-02T19:38:19+00:00Added an answer on June 2, 2026 at 7:38 pm

    Can’t really explain why your query got slower when converted into a view by phpMyAdmin, but I would try the following query instead:

    SELECT
      uuid,
      creator,
      GROUP_CONCAT(CASE type WHEN 'name' THEN name END) AS names,
      GROUP_CONCAT(CASE type WHEN 'tag'  THEN name END) AS tags
    FROM tags
    WHERE type IN ('name', 'tag')
    GROUP BY
      uuid,
      creator
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have managed to write some code that should print the source
I have managed to create a custom action in C# using MakeSfxCA which is
I have managed to bring the following output with this query SELECT DISTINCT IF(purchaseproduct_customerid=0,contactperson,vendorname)
I have managed to put this condition and rule below together to redirect a
I have managed objects that have image properties. Since storing large blobs in CoreData
I have been required to write a function that reads the BSDF data format
I have to write a query in sqlite to update the record if it
Does anyone know if it is possible to write a query that can produce
How to write joins in django,i have gone through below django documentation ,but joins
I have a structure like below that needs to be saved and loaded from

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.