2 added wtd_art_categories table screenshot
source | link

I have a category page as below:

enter image description here

and when a category is clicked, using the following code

$sql_categories = $wpdb->prepare ("SELECT * FROM ".$wpdb->prefix."wtd_art_categories WHERE Parent = %d ORDER BY Id", $_GET['c']);
$get_categories = $wpdb->get_results( $sql_categories );

it queries sub categories and then I display on the same page. (Example Shapes clicked):

enter image description here

Since each time there is a query, I thought this is causing the delay, and I used a session variable to keep the $wpdb->get_results , however still it is not fast as I expected.

What kind of trick can I use to increase speed of navigation inside these categories ?

Edit: wtd_art_categories table: (Data is dummy) enter image description here

I have a category page as below:

enter image description here

and when a category is clicked, using the following code

$sql_categories = $wpdb->prepare ("SELECT * FROM ".$wpdb->prefix."wtd_art_categories WHERE Parent = %d ORDER BY Id", $_GET['c']);
$get_categories = $wpdb->get_results( $sql_categories );

it queries sub categories and then I display on the same page. (Example Shapes clicked):

enter image description here

Since each time there is a query, I thought this is causing the delay, and I used a session variable to keep the $wpdb->get_results , however still it is not fast as I expected.

What kind of trick can I use to increase speed of navigation inside these categories ?

I have a category page as below:

enter image description here

and when a category is clicked, using the following code

$sql_categories = $wpdb->prepare ("SELECT * FROM ".$wpdb->prefix."wtd_art_categories WHERE Parent = %d ORDER BY Id", $_GET['c']);
$get_categories = $wpdb->get_results( $sql_categories );

it queries sub categories and then I display on the same page. (Example Shapes clicked):

enter image description here

Since each time there is a query, I thought this is causing the delay, and I used a session variable to keep the $wpdb->get_results , however still it is not fast as I expected.

What kind of trick can I use to increase speed of navigation inside these categories ?

Edit: wtd_art_categories table: (Data is dummy) enter image description here

1
source | link

Performance optimization of tree like structure

I have a category page as below:

enter image description here

and when a category is clicked, using the following code

$sql_categories = $wpdb->prepare ("SELECT * FROM ".$wpdb->prefix."wtd_art_categories WHERE Parent = %d ORDER BY Id", $_GET['c']);
$get_categories = $wpdb->get_results( $sql_categories );

it queries sub categories and then I display on the same page. (Example Shapes clicked):

enter image description here

Since each time there is a query, I thought this is causing the delay, and I used a session variable to keep the $wpdb->get_results , however still it is not fast as I expected.

What kind of trick can I use to increase speed of navigation inside these categories ?