python – CSES standard solution for range query problem giving TLE

Problem statement is from CSES

This is a standard question where we are given a list of numbers and a number of queries. For each query, you have to give the sum of numbers in the given range.

My implementation in python:

def solve():
    n,q = (int(a) for a in input().split(' '))
    arr = (int(a) for a in input().split(' '))
    cumulativeArray = (0) # Initial entry added to make 1 based indexing
    sum = 0
    for i in range(len(arr)):
        sum += arr(i)
    for i in range(q):
        x,y = (int(a) for a in input().split(' '))
        print(cumulativeArray(y) - cumulativeArray(x-1))

This gives the required answers correctly for all my custom test cases. But gives TLE for huge test cases.

I believe this is happening due to split() method in my code.
Any leads are welcome.

seo – Does rearranging query parameters result in duplicate content?

With regards to duplicate content, as long as the correct canonical tag is set to match the original page, it should be fine.

In saying that, it’s definitely not optimal to have duplicate pages with exactly the same content on them, and then rely on the canonical tag to get you out of trouble with the duplicate content.

With regards to the redirect question, if the page URL (with or without the query parameter) doesn’t really exist, then it should go to a 404 page. The last thing you want is loads of internal 301’s for no reason. The less 301’s you have on your site the better.

(And if you’re worried about the visitor experience going straight to a 404, then just implement a site map or menu on your 404 page to help the visitor choose where to go).

But it also sounds like a bit of a unique case with your query parameters. So you could implement a wildcard redirect in htaccess if those URLs should all definitely resolve to that single page etc.

mongodb – Query doesn’t return data that’s written recently

I have two micro services where one write to DB and another read from DB.

The first micro service is written in C++ while the other is written in NodeJS.

When querying for data say for a IP the MongoDB return older data or no data at all (In case if the client is new) but If I query like say after 5 min it returns the recent data.

I don’t think this has to do with concurrency at all because C++ is performant enough to write to DB faster

High CPU when executing a Postgres query spanning multiple tables

We have an application which executes jobs. The job usually consists of a single transaction in which around 4k rows are inserted/updated across 13 relations.
The transaction takes around 2 minutes to execute.

This job leads to a CPU spike on the server.

Is there a way to fine tune the config to avoid this spike?

Query resource quota for PostgreSQL accounts

Within the latest (12, 13) versions of PostgreSQL, is there any throttling support on the user-account level, to limit how much data any query can produce and/or how much time + memory it may consume under that user account?

I want to limit specific user accounts to allow up to certain amount of data and/or time to consume within the server, before erroring with “query quota exceeded” or something like that.


I want to configure user account guest to produce “quota exceeded” failure for any query that returns more than 10kb of data or takes more than 10 seconds to execute.

clustered index – Cluster is causing my query to run SLOWER then before

So I have been stuck on this for 6 hours now and I have no clue what to do. I am doing university homework that requires us to create a unoptomized sql query (does not have to make sense) and then apply index’s and see if it makes it faster (which it did for me, from 0.70 elapsed time to 0.66) and then we had to apply clusters.

I applied clusters and it has now almost doubled the amount taken to finish the query. From 0.70 to 1.15. Below is how I specified my cluster:

CREATE CLUSTER customer2_custid25 (custid NUMBER(8))  

SIZE 270

TABLESPACE student_ts; 

I tried all my previous times with INITIAL and NEXT but that seemed not to make a difference. Below are the tables:


    CustID         NUMBER(8) NOT NULL,
    FIRST_NAME     VARCHAR2(15),
    SURNAME     VARCHAR2(15),
    ADDRESS     VARCHAR2(20),

    CLUSTER customer2_custid25(CustID); 

CREATE TABLE product18( 

    ProdID     NUMBER(10) NOT NULL,
    PName    Varchar2(6),
    PDesc    Varchar2(15),
    Price    Number(8),
    QOH        Number(5)); 

CREATE TABLE sales18( 

    SaleID     NUMBER(10) NOT NULL,
    SaleDate    DATE,
    Qty            Number(5),
    SellPrice    Number(10),
    CustID        NUMBER(8),
    ProdID        NUMBER(10)) 

    CLUSTER customer2_custid25(CustID); 

CREATE INDEX customer2_custid_clusterindxqg ON CLUSTER customer2_custid25 TABLESPACE student_ts ; 

I also tried taking the tablespace section in the cluster index away.

I followed this formula to help calculate cluster sizes:

“Size of a cluster is the size of a parent row + (size of Child row *
average number of children). “

This brought me to the size of 270. However, after testing sizes (going up 20) from 250 to 350 I found 320 to be the fastest at 1.15.

No matter what I try, I can not for the love of me get it lower then my base query times.

Other students have done the same and halved their query time.

All help is really appreciated.

hooks – SharePoint online search query from Drupal in logged in user context, which is connected through SIMPLESAML SSO (Azure AD IDP) with PHP application

Below is problem description –
I have sharepoint online and its URL is like –

Above sharepoint is connected through SSO (Office 365 Azure AD IDP and SAML)

I have another Drupal 8 application like –

It is also connected through same SSO (Office Azure AD and SAML) so that if user login through either of application through SSO then he is allowed to login in another application as well. It means application is Single sign on enabled. and its working fine.

Now as a user, i am able to login through using SSO (office 365 azure AD and SAML ). Now after user login being developer, i need to show recent modified SharePoint document from SharePoint online using SharePoint REST query but condition is that, it should fetch only documents on which logged in user has permission to show.

Brief requirement –

The requirements is to be able to make REST queries to SharePoint online but when the REST query is made, the person the query is for must only see the results based on their security context.

So if user1 has access to a SharePoint folder but user2 has not, then when the REST call is made they will each see a different set of results.

Example: user1 has access to User2 does not have access to the folder and so he will not have access to

If some updates this document it becomes a “Latest Update”. User1 will see it in the Latest documents but User2 will not.

I tried using PHPSPO library ( and it giving me result but this library is giving me result based on admin credential which I pass to connect SharePoint.

How can i achieve this in logged in user context. Considering user is already login through SSO.

I also tried to make AJAX query from drupalapp but it always giving me CORS error.

Please help me to solve this problem.


google bigquery – Big Query – Concurrency for dashboard design

Is big query suitable to handle hundred of thousands of connections or this is a bad design?

Situation, currently building a dashboard that will display aggregated values pulled straight from big query. In our dashboard, we also have a set of date filters that can display up to previous year worth of data(each filter will be a unique query to big query). It’s highly possible that hundreds of thousands of users will access the dashboard at the same time.

Read from the documentation that big query has a set quota on the number of queries that can be run at the same time.

If this is really a problem, the solution I’m planning is to precalculate every unique date results and persist it in fast table but we are talking a lot of combinations in here. Is this the right architecture to go or big query has another trick in the bag to address this concern?

wp query – SQL to join u3g_users & u3g_meta_value with repeating data

I’m using the below SQL to create a table from wordpress user information joining data in u3g_users and u3g_metavalue.

SELECT u3g_users.`ID`,
       u3g_users.`display_name` AS `Name`,
       u3g_users.`user_email` AS `Email`,
       u3g_users.`user_login` AS `Login (Email)`,
       u3g_usermeta.`meta_value` AS `Address #1`
FROM u3g_users

INNER JOIN u3g_usermeta
     ON u3g_users.`ID` = u3g_usermeta.`user_id`
WHERE meta_key = '#address1'

The code as it is shows 2 users out of 183 that have actual values for the meta_key set as #address1

I’m trying to expand the code to show the following but can’t seem to get there.

  1. The current code shows me the results of just two user where the meta_value has a value. I need it to show ALL Users even if the meta_value is blank.

  2. The meta_key also contains additional sections for which I need to expand on for example #address #2 I’ve tried to make a repetition to show a sixth column which should be ‘#Address2’ for example the column headings would be Name, Email, Login(Email), Address #1, Address #2

The goal is to create an SQL code that combines u3g_users & u3g_meta_value with repeating columns of meta_value so that the user can see a better defined user database on the front end even is the data is blank

Any pointers would be great

Thanks in Advanced

caml query – Add multiple Fields For the CamlQuery in Sharepoint Hosted App

I try to filter two Fields or more that is clean of null values, it works for the first field but it does not for the second:

<View><Query><Where><IsNotNull><FieldRef Name='CustomField'/></IsNotNull><IsNotNull><FieldRef Name='LaborCategory'/></IsNotNull></Where></Query></View>