I would like to use Set::extract to pull back something like this.
Set::extract('/User[region_id=1 or email_region_id=1]', $users);
I could probably do this with multiple queries but I am not sure if this would be faster. It would definitely be easier given the current setup.
thanks for your help
This doesn't look possible at the moment.
Related
I am trying decide which tool works best for my organization. For that reason I am testing performance of powerbi, looker and tableau against bigQuery etc. Since this is a benchmarking exercise and I am planning to test it for multiple iterations, I want to disable the result set caching property of big Query. In the official documentation, they are letting us disable by passing query config use_query_cache=False
Since I am connecting from front end tools, I am not really sure how to pass this parameter. Can someone help in achieving this? or alternative options if available?
I've not tried this, but I'd think it could be passed like other options.
In this documentation, they have code that looks like this:
Source = GoogleBigQuery.Database(
[BillingProject="Include-Billing-Project-Id-Here", UseStorageApi=false])
I'd expect your parameter to look similar. I.e.
Source = GoogleBigQuery.Database(
[BillingProject="Include-Billing-Project-Id-Here", UseQueryCache=false])
I am locking for a read-write lock in Django, using PostgreSQL.
I know select_for_update
On top, I need SELECT FOR SHARE
I founds this super old Django-ticket
I couldn't find any third party library implementing this for Django
Now I am wondering:
Is there a good reason this was not implemented in the Django-ORM?
Does anyone know any third party library for this?
Or any easy work around?
Can't you wrap the logic in pl/pgsql function that uses select for share and you then call the function from django?
Is there a good reason this was not implemented in the Django-ORM?
The ticket you've posted probably provides the reason: no one is motivated enough to write a patch.
Does anyone know any third party library for this?
Not me, sorry.
And if by any chance you are thinking about ditching Django for some other ORM then you must ask yourself: "There is a feature I need that's missing in Django... what features will I miss in this other ORM?"
Or any easy work around?
Probably not. But here are some options:
Every ORM I know has an escape hatch to raw SQL. You probably know that, but reluctant to use it... But, as you also lack the motivation to make a pull request, that probably means that you do not have hundreds of requests that require SELECT FOR SHARE functionality. So you should consider it. Performing raw SQL queries
Stored procedures as steve mentioned
https://docs.djangoproject.com/en/3.0/topics/db/sql/#calling-stored-procedures
The last comment on the ticked you've posted is from a man (David Schwärzle) who claims that he has a solution (not for PostgreSQL specifically but a solution nevertheless)... maybe you should try and contact him.
Haven't tried it, but probably the way you can add the desired functionality is by Writing your own Query Expressions
You can easily implement with a raw query.
from django.db import connection
query = f"""SELECT * FROM "appname_modelname" WHERE id={obj_id} FOR SHARE"""
with connection.cursor() as cursor:
cursor.execute(query, None)
obj_id is python variable.
appname_modelname is name of table created in your db by django. Django by default combines lowercased app name and model name with underscore.
With beta4 and latest beta5 the DB-Feature-Implementation appears to have pretty much finished. There's a couple of tutorials out there how to handle a single Database using the TableGateway Pattern, but it appears there is none for handling M-N-Relationships.
In ZF1 we had findDependantRowset() on the TableGateway which was kind of dirty, as this simply was a second Query to the databse which pretty much isn't always neccessary.
In ZF2 i expected there to be a way to have good Joins mapping to specified models, but i can't find anything within the code. Maybe i'm blind, maybe there really isn't anything like this.
Has anyone of you managed to handle joins and models all together in ZF2? If so, please be so kind to instruct me how to do it, hint me to specific points of the documentation or link me some blogpost to one who has done it.
Thanks in advance guys!
The obvious solution if you need a generic solution is to use Doctrine ORM or Propel.
If you want to use Zend\Db, then within your concrete table gateway classes, you should write a specific method that retrieves the correct rows from the linked table. This way you can ensure that the SQL is optimised for the query that you need.
Has anyone used the EmpireDB from Apache? I am planning to use it and would like to know if there are any known issues with this new concept?
I have used ORM like Hibernate and JPA. But EmpireDB sounds like it easy.
Anyone knows its limitations then please let me know.
Thanks.
EmpireDB places impositions on your model classes; you can't just persist your designed model. You add a dependence to their codebase (which could change later). You have to write a lot more code to use it (using its Tutorial) than you would using JDO or JPA. How that is somehow "easy" i can't think.
If you need full control over the sql, you don't want to use entities for everything and hate sql/jpql strings it is the perfect tool.
It depends largely on what you plan to do with it.
Hi
I need to optimize an application which is already there for a long time. Optimization will include move inline queries from php pages to "stored procedures", get rid of sub queries and convert them to "joins" etc etc.
I guess the best way is to use benchmarking tools for this purpose, but is there any GUI based tool available which I could use with Windows 7? Please help!
Also moving the inline queries to stored procedures and getting rid of sub queries, will that help in a major performance boost? Please feel free to express your opinion.
The major focus is on finding a suitable tool for benchmarking purposes however. Just a quick question will "Mysql workbench" help in this scenario? Pls advise.
Many thanks for your time in advance. Any kind of help is much appreciated.
I do not know about the moving the inline queries to stored procedures. It really depends if you are going to use that query a lot or not. Switching from usign many queries to JOIN coudl be a major improvement in most cases, depends how much extra queries you were running initially.
As for benchmarking, well you can always use even phpMyAdmin to see how much time are takign certain queries and/or use a build in application benchmakring/profiling tool (even created from you PHP code) to bench the performance. This things usually do not have a straight and simple answer :(
Link with some suggestions http://beerpla.net/2008/04/16/mysql-conference-liveblogging-benchmarking-tools-wednesday-425pm/ maybe try WAST http://west-wind.com/presentations/webstress/webstress.htm
If you have a DB abstraction layer use it to log the performance of the queries and see if there are any that repeat too often or take too much time and also in which script they where called.