Suddently slow SELECT

I noticed that one of my Hibernate JPA SELECTs against my Heroku PG 10.4 instance is taking a loooog time to complete as this EXPLAIN (ANALYZE, BUFFERS) shows. The database is 591MB running in PG 10.4 on Heroku with the following row counts and index use:

    relname     | percent_of_times_index_used | rows_in_table   ----------------+-----------------------------+--------------- fm_order       | 99                          |       2233237 fm_grant       | Insufficient data           |        204282 fm_trader      | 5                           |         89037 fm_capital     | 99                          |         84267 fm_session     | 99                          |          7182 fm_person      | 99                          |          4365 fm_allocation  | 96                          |          4286 fm_approval    | Insufficient data           |           920 fm_market      | 97                          |           583 fm_account     | 93                          |           451 fm_marketplace | 22                          |           275 

and the offending JPA JPQL is:

@Query("SELECT o FROM Order o WHERE                                "      + "       o.type                  = 'LIMIT'                   "      + "   AND o.session.original      = :originalSessionId        "      + "   AND ( (                                                 "      + "         o.consumer IS NULL                                "      + "    ) OR (                                                 "      + "         o.consumer IS NOT NULL                            "      + "     AND o.consumer > 0                                    "      + "     AND EXISTS (                                          "      + "       SELECT 1 FROM Order oo WHERE                        "      + "                       = o.consumer         "      + "         AND oo.session.original      = :originalSessionId "      + "         AND oo.type                  = 'LIMIT'            "      + "         AND oo.owner                != o.owner            "      + "     )                                                     "      + "   )                                                       "      + " )                                                         "      + " ORDER BY o.lastModifiedDate DESC                          ") 

which Hibernate turns into:

SELECT                 AS id1_7_,        order0_.created_by         AS created_2_7_,        order0_.created_date       AS created_3_7_,        order0_.last_modified_by   AS last_mod4_7_,        order0_.last_modified_date AS last_mod5_7_,        order0_.consumer           AS consumer6_7_,        order0_.market_id          AS market_14_7_,        order0_.original           AS original7_7_,        order0_.owner_id           AS owner_i15_7_,        order0_.owner_target       AS owner_ta8_7_,        order0_.price              AS price9_7_,        order0_.session_id         AS session16_7_,        order0_.side               AS side10_7_,        order0_.supplier           AS supplie11_7_,        order0_.type               AS type12_7_,        order0_.units              AS units13_7_ FROM   fm_order order0_        CROSS JOIN fm_session session1_ WHERE  order0_.session_id =        AND order0_.type = 'LIMIT'        AND session1_.original = 7569        AND ( order0_.consumer IS NULL               OR ( order0_.consumer IS NOT NULL )                  AND order0_.consumer > 0                  AND ( EXISTS (SELECT 1                                FROM   fm_order order2_                                       CROSS JOIN fm_session session3_                                WHERE  order2_.session_id =                                       AND = order0_.consumer                                       AND session3_.original = 7569                                       AND order2_.type = 'LIMIT'                                       AND                      order2_.owner_id <> order0_.owner_id) ) ) ORDER  BY order0_.last_modified_date DESC; 

Any ideas how I turn this 320S disaster around?

Firefox loads google searches quickly, but website loading is slow

I’m brand new to Linux and Ubuntu and I have this issue on both my laptop and desktop, both run Ubuntu 18.04.1 LTS. When I run a speedtest it shows that I get 250Mbs+ but websites take forever to load. When I switch to Windows 10 everything is back to normal. Suggestions?

Update: I tried Chromium and it’s lightning quick. So it is definitely a Firefox problem.

Why are bulk multi-column key queries so slow in MySQL?

(For this question, I am using AWS/Aurora MySQL with a reasonably-spec’d RDS instance)

Consider the following schema:

Table T:     col0: the usual autoincrement primary key     col1: varchar     col2: varchar     col3: varchar     col4...N: various data 

Consider that there is a unique index on:

<col1, col2, col3> 

And a non-unique index on:

<col1, col2> 

And consider the following query:

SELECT * FROM T WHERE     (col1 = 'val1' AND col2 = 'id1') OR     (col1 = 'val2' AND col2 = 'id2') OR     ...     (col1 = 'valN' AND col2 = 'idN'); 

I would (perhaps naively) expected MySQL to figure out that each element of the OR set matched the (non-unique) index, and performed the query in the way it would have if I had said:

WHERE col0 in (v1, v2, ... , vN) 

But it doesn’t seem to do that: the timing for these two queries is WAY OFF, on the order of 10x slower for the “or of ands” query. EVEN WITH the secondary key lookup, and the fact that it’s a string column lookup, 10x seems a bit severe. Note that EXPLAIN claims to be using the correct/expected index whether I specify (col1, col2) or (col1, col2, col3)

Please note also that:

SELECT * from T WHERE     col1 in (list1) AND     col2 in (list2); 

Is also slow when there are a lot of different values in list1 and list2. Doing an “and” for the three columns is almost intractably slow.

Perhaps not surprisingly, this query works better than the “or of ands” when list1 is of length 1.

My python code is too slow

I am trying to solve some challenges and I noticed that my python code runs too slow. When I wrote the same code in Java, I didn’t have any problem. Some could tell me how to improve my python code?

Java code:

    import java.util.Scanner;  public class PrimeKattisChallenge2 {      public static boolean isPrimeNumber(int number) {         if (number == 2)             return true;         if (number % 2 == 0)             return false;         int sqrt = (int) Math.sqrt(number);         for (int i = 3; i <= sqrt; i += 2)             if (number % i == 0)                 return false;         return true;     }      public static void verifyOutput(int number, int count) {         count++;         if (isPrimeNumber(number)) {             System.out.println(number + " " + count);             return;         }         int factors = 0;         int i = 2;         while (true) {             if (number % i == 0) {                 number /= i;                 factors += i;                 if (isPrimeNumber(number)) {                     factors += number;                     break;                 }                 i = 1;             }             i++;         }         verifyOutput(factors, count);     }      private static void printOutput(int number) {         verifyOutput(number, 0);     }      public static void main(String[] args) {         Scanner scan = new Scanner(;         while (true) {             int number = scan.nextInt();             if (number == 4) {                 break;             }             printOutput(number);         }         scan.close();     } } 

Python code:

    import sys from math import sqrt  def is_prime_number(number):     if number == 2:         return True     if number % 2 == 0:         return False     sqr = int(sqrt(number)) + 1     for divisor in range(3, sqr, 2):         if number % divisor == 0:             return False     return True        def verify_output(number, count=0):     count+=1     if is_prime_number(number):         print(number, count)         return     factors = 0     i = 2     while True:         if number % i == 0:             number = number // i             factors += i             if is_prime_number(number):                 factors += number                 break             i = 1         i+=1     verify_output(factors, count)  for item in sys.stdin:     item = int(item)     if item == 4:         break     verify_output(item) 

Ubuntu 18.04 boot time is very slow (userspace taking a lot of time)

I have dual booted Ubuntu along with Windows 10. I have a SSD+HDD combo where Windows is installed on SSD and Ubuntu on HDD.

I’ve tried reinstalling Ubuntu but the problem of large boot time still persists

The boot time calculated by the linux system on the command systemd-analyze time is as follows:

Startup finished in 6.208s (kernel) + 1min 21.627s (userspace) = 1min 27.835s reached after 1min 18.951s in userspace

On knowing time taken by different processes systemd-analyze blame It prints:

34.239s dev-sda3.device          26.287s plymouth-quit-wait.service          22.271s systemd-journal-flush.service          14.668s systemd-udevd.service          14.500s plymouth-start.service          13.720s snap-gnome\x2d3\x2d26\x2d1604-70.mount          13.240s snap-gtk\x2dcommon\x2dthemes-319.mount          12.755s snap-gnome\x2dsystem\x2dmonitor-51.mount          10.934s snap-gnome\x2dcharacters-103.mount          10.220s snapd.service           9.661s snap-core-4917.mount           7.689s NetworkManager-wait-online.service           7.167s udisks2.service           7.020s NetworkManager.service           6.830s ModemManager.service           6.778s accounts-daemon.service           5.207s bolt.service           5.128s networking.service           4.559s networkd-dispatcher.service           4.173s rsyslog.service           3.921s systemd-tmpfiles-setup-dev.service           3.750s thermald.service           3.510s polkit.service lines 1-23 

Please help!

Flash Player loads object/videos slow on all browsers

So i have a user who is trying to load an E-Learning course that uses Flash as a slideshow type of thing and it takes forever to load on his PC. I tried it on another PC that is in the building and it too took forever to load no matter what browser you launch the course on.

Now i tried the same website on my office PC that’s offsite elsewhere and it loaded the flash objects instantly.

The user claims that he had the same issue last time and claims it was the firewall but based on the past tickets he’s submitted, it was not. They have a Cisco ASA 5505 and the only thing that would, if any, affect it would be traffic policing but its only policing up to their total bandwidth.

I have tried:

  1. Clearing Temp with CLEANMGR.
  2. Clear Browser Cache, History, Cookies.
  3. Try IE, Chrome and Firefox (IE so far is doing way better).
  4. Double Check firewall to make sure nothing is being blocked.
  5. Ran speed test to make sure he doesnt have slow internet, currently has ~40mbps x 40mbps.
  6. Tried different user accounts.
  7. Toggle on/off HW Acceleration on Flash setings and on Browser settings.

None of this has ever made flash load fast enough compared to my office PC.

Any ideas what could be the cause and if there is a fix for this?

Cut & Paste rows to new sheet based on differant criteria in Column A – code running slow

I have a “working sheet” that contains 15000+ rows.
In column A is an identifier for that row. There are over 20 different identifiers i.e 9W, AM, AV, BG, CY, HJ etc. etc.

My current code looks for each row on “Working Sheet” that has 9W in column A, cuts and pastes that row into a sheet called 9W.
Once finished it moves to AM, finds am in Column A , cuts and pastes each row into a sheet called AM. Process repeats until all Identifiers have been done.

Below is a sample of the current code that i have created with my limited knowledge.

Sub Test()  'Do 9W      Dim sht1 As Worksheet, sht2 As Worksheet     Dim i As Long      Set sht1 = ThisWorkbook.Worksheets("Working Sheet")     Set sht2 = ThisWorkbook.Worksheets("9W")      For i = 2 To sht1.Cells(sht1.Rows.Count, "A").End(xlUp).Row         If sht1.Range("A" & i).Value = "9W" Then             sht1.Range("A" & i).EntireRow.Cut sht2.Range("A" &   sht2.Cells(sht2.Rows.Count, "A").End(xlUp).Row + 1)         End If     Next i  'Do AM  Dim sht3 As Worksheet, sht4 As Worksheet Dim i1 As Long  Set sht3 = ThisWorkbook.Worksheets("Working Sheet") Set sht4 = ThisWorkbook.Worksheets("AM")  For i1 = 2 To sht3.Cells(sht3.Rows.Count, "A").End(xlUp).Row     If sht3.Range("A" & i1).Value = "AM" Then         sht3.Range("A" & i1).EntireRow.Cut sht4.Range("A" &  sht4.Cells(sht4.Rows.Count, "A").End(xlUp).Row + 1)     End If Next i1  'DO AV  Dim sht5 As Worksheet, sht6 As Worksheet Dim i2 As Long  Set sht5 = ThisWorkbook.Worksheets("Working Sheet") Set sht6 = ThisWorkbook.Worksheets("AV")  For i2 = 2 To sht5.Cells(sht5.Rows.Count, "A").End(xlUp).Row     If sht5.Range("A" & i2).Value = "AV" Then         sht5.Range("A" & i2).EntireRow.Cut sht6.Range("A" &  sht6.Cells(sht6.Rows.Count, "A").End(xlUp).Row + 1)     End If Next i2  'DO BG  Dim sht7 As Worksheet, sht8 As Worksheet Dim i3 As Long  Set sht7 = ThisWorkbook.Worksheets("Working Sheet") Set sht8 = ThisWorkbook.Worksheets("BG")  For i3 = 2 To sht7.Cells(sht7.Rows.Count, "A").End(xlUp).Row     If sht7.Range("A" & i3).Value = "BG" Then         sht7.Range("A" & i3).EntireRow.Cut sht8.Range("A" &      sht8.Cells(sht8.Rows.Count, "A").End(xlUp).Row + 1)     End If Next i3  End Sub 

Slow WiFi connection on Ubuntu 18.04.1

I am new to Ubuntu and after I installed Ubuntu on my PC, I am experiencing a terribly slow WiFi connection (but faster on Windows). I tried to disable the 802.11n and the Intel driver card but it gives me the following error (running sudo modprobe -r iwlwifi):

rmmod: ERROR: missing module name. modprobe: FATAL: Error running remove command for iwlwifi 

I also tried following this answer but lspci -nn | grep 0280 returns nothing on my Terminal.

When running lspci -knn | grep -i net it returns:

00:19.0 Ethernet controller [0200]: Intel Corporation 82567LM-3  Gigabit Network Connection [8086:10de] (rev 02) Subsystem: Dell 82567LM-3 Gigabit Network Connection [1028:027f] 

Any help would be appreciated. Thank you so much!

composer update –no-dev made website super slow

Im new to Magento 2.3,

first I had an issue installing anything through composer because it was saying that my php 7.3 doesnt meet requirements which is 7.1 or 7.2. My php actually 7.1, so I don’t know how it was reading 7.3, anyways I went and edit composer.json and added:

"platform": {              "php": "7.1.25"     }, 

That helped and I was able to install all applications that require composer. After I went to extension manager and decided to install another application through marketplace and got a Readiness Red mark about dependencies issue, obviously because I edit my composer file. So somewhere I read that I should do

composer update –no-dev

, I know stupid and even though after I did

composer update

and everything was installed again, my website became super slow, can’t open extension manager anymore. Please help me fix it.