Answer the question
In order to leave comments, you need to log in
How expensive is it to use sql database connections like this?
I am using uikit slideset which will convert html with special attributes to my code
like
<div data-uk-slideset="{default: 4}">
<ul class="uk-grid uk-slideset">
<li>...</li>
<li>...</li>
</ul>
<ul class="uk-slideset-nav">...</ul>
</div>
$('.myobject').click(function() {
$(this).html('<div data-uk-slideset="{default: 4}"><ul class="uk-grid uk-slideset"><li>...</li><li>...</li></ul><ul class="uk-slideset-nav">...</ul></div>');
});
<div class="myslideset" style="display:none">
<div data-uk-slideset="{default: 4}">
<ul class="uk-grid uk-slideset">
<li>...</li>
<li>...</li>
</ul>
<ul class="uk-slideset-nav">...</ul>
</div>
</div>
$('.myobject').click(function() {
$(this).html( $('.myslideset') ).children('.myslideset').css("display","block");
});
Answer the question
In order to leave comments, you need to log in
But I know what kind of people will need it, because before that they have a special value in the sql database.
In any case, you pull out the authorization data and save it to the session. Joy the flag (UI marker) for displaying the menu.
If you do not have some kind of role/group access model, then create UI markers - what to display for this user.
Of course, the approach decided not to bother has the right to life. But you have to be disciplined.
Most likely, you save on matches. Yes, it will eat up some milliseconds of page loading and some kilobytes of memory, but if your server is not running on a wristwatch, you will not notice the difference.
Well, no one forbids caching the value in the session.
I read a little diagonally, so do not be offended if the advice of the council will echo your outpourings. You have a general list of elements and its subset - a list available to a certain user (by roles or access rights - it doesn't matter). p.1) If these access rights are stored in the database, then just drag from the database only what is potentially necessary for this client. By the way, this data is quite static, so you can safely cache it. p.2) about "only 300kb". Yes, for one user they will be cached, but the first run will be long, but not for another. and with 100k uniks, these 300kb will be given to everyone for the first time, although there is a risk that they are not needed. p.3) Where are these images stored? if in the database, then we again get an extra load on the server for data that it does not need. In my opinion, one of the main rules for such tasks on the load on the database is never drag extra data. Let the base filter them out better than you first dragging a hefty data packet to the application server, then finding out which ones are needed and which are not, then throw all this dump to the client "maybe come in handy."
> The bottom line is that let's say this is a super visited site - 100,000 unique per day ..
you flatter yourself a lot :)
first make a site, and only then do pointwise optimization of braking queries. now you are not doing that
Oh lol .. I came up with the simplest solution for my task - in general, everything will be created when the page loads, it will be hidden, BUT without pictures (empty src) .. just then WHEN CLICKING, the src attribute for all images will change and the desired path will be distributed by id.
But still, the question about databases remains open, I'm just wondering -
How expensive is it to use connections to the sql database on each page load, given the huge number of such downloads per day?
PHP
[connect to db
select values, check
many many code
closing connection] x ~500k-1 million times per day
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question