Software Engineer
Great Software Laboratory (GSLab)PHP developer
Earth Solution Private LimitedJira
Jenkins
Uh, I have more than 7 years of experience in, uh, PHP Laravel and along with Python as well, MySQL and JavaScript.
Well, uh, in in, uh, in one of our table locations, it has a huge data, like, 50 to 60,000 rows. So we have to optimize it. So for that, we have written stored stored procedure and done indexing on the on the columns. And and while fetching the data, we have used group by and many other options. So that has, uh, improved the speed of the data. Also also, from point of view, we have used lazy loading.
Uh, well, I will use transactions, DB transactions. So in case if if, uh, if anything fails, uh, I will roll back all the transaction. If anything goes well, I will commit the transaction. So this will happen data integrity.
Will you connect with the front end developers about what they want, what data they want? So so, accordingly, you would then, uh, you you you you then structure that data in the same way. And and and, also, you you need to understand how how much, uh, how much large is that dataset, whether you whether you have to send all the data at once or you can send the data in chunks.
So for that, we can use this caching Redis cache so far. So if if, uh, if I'm requesting a data, if there's so if let's say, an example, if there's data and I'm using API to fetch it, what I what I can do is I can use a cache. I can cache the, uh, data so that will improve in the the in in the in the speed. So that will have an improvement in the speed. So say for for for example, if if new data is inserted in the same table, so, uh, I will I will clear the I will clear the cache, and that will help in in up updating the data as well.
I have not implemented it, but other like this, uh, singularity, like, like, other solid principles like dependency uh, inversion. I have I have used that, but not this, uh, list cost of solution principle.
Well, what you can do is you can create a middleware as an as an abstraction layer and and, uh, and and in that, you you will have the header. So that way, that header so that way, that header will apply to all the all the all the rest APIs. Instead of, uh, instead of writing here, it's better to create a different class and then use that class to implement it. That way, we can use that middleware on or that class anywhere in the in the application.
Well, in here, we have to use this parameterized video. Like like, instead of directly writing this this query, this is prone to MySQL injection. So instead, we should have parameterized, uh, query and and and, uh, and also we have to sanitize the data first like like email. Like, we have to remove the the tags. We have to remove any script tags.
Well, one of the use cases we have we had are are already in the table. Like, it it it it wasn't more one to one relationship. But later on, the data got so big, so we have to change the relationship. Already, that data was in the table. So what we do is we created we replicated the same same table and used the one to many relationship in that.
So for that, you need to have the first thing. You you you need to exceptions. So in case if anything fails, the users should know. We can have, uh, we can use events. So in case if if, uh, if if anything failure happens also, uh, if if a cron job is running, it's better to, uh, implement the Apache, uh, airflow. So that is more resilient.
So firstly, uh, what you can do all the you you we need to cache all the static files. Okay. And and then, uh, we have to cache all the views and and and and routes as well. So that way the application will be faster. And also, uh, in in the in the views, we have to load the CSS file first and and after the page loads, then the JS. That way, it will speed up the application.
It completely depends upon the use cases. Like, if if I have a query, uh, like, if if I have SQL query, whether that will, uh, give me the result with ORM or that will give me the result with raw raw SQL. So it all depends upon the the speed, how how much time will it consume, and how much simpler will I write Will, uh, do I have do I have all the options with Laravel or not?