sql server – SQL – global temporary table versus normal table

I have a stored procedure that I use to load csv files to SQL. Initially, this will massively insert the file into a global temporary table and then at the end it will do:

select cast(column1 as int) (column1), column2, column3... into table from ##temptable

and then proceed to release the temptable ##

Before "selecting in the table from ## temptable" I run a series of selection queries in the temporary table to determine what the columns should be (and I'm sure this works correctly).

Note that having a table (normal or temporary) before creating the final output table is essential for the stored procedure.

What I would like to know is if it is better to use a global temporary table or if I should use a normal table or does it make no difference?

I have seen several articles on the differences between temporary tables and table variables, but I have not seen anything when it comes to comparing global temporary tables with normal tables and it is difficult for me to test this correctly in my environment.

Temporary access to the page with URL sent to the email

I want to protect a certain page with a password. The problem is that I want to unlock it for users who have an active reservation (I am using WooCommerce reservations). I thought that a good idea could be to send an email to each user with an active reservation X minutes before the actual reservation begins with a private and temporary link to that blocked page. The link must use a token to unlock it automatically.
I don't know if this is possible in the WordPress environment.

Thank you!

Algorithms – Temporary complexity of simple functions related to bits

I wonder about Right Answer this task from a test yesterday:

A function Pow that calculates $ y = a ^ k $ it occurs where $ k $ is a
integer length $ n $ bits:

function Pow(a, k)     { k >= 0 }
    z := a;
    y := 1;
    m := k;
    while m != 0 do
        if m mod 2 = 1 then
            y := y * z;
        end if
        m := m div 2;
        z := z * z;
    end while
    return y;
end function

Calculate the complexity of the weather in the worst case and the average time
complexity of this function. The dominant operation is a comparison
operation performed on line 6. Briefly describe the value of $ k $ when
The worst case occurs.

So, I think the number of comparisons depends on the length of $ k $ in terms of its bits.

Leave $ k = 0 $: (binary $ 0 $ also what is $ 1 $ little bit):

$ Rightarrow 0 $ comparisons

Leave $ k = 1 $: (binary $ 1 $ also what is $ 1 $ little bit):

$ Rightarrow 1 $ comparison

Leave $ k = 8 $: (binary $ 1000 $ which $ 4 $ bits)

$ Rightarrow 4 $ comparisons

Leave $ k = $ 15: (binary $ 1111 $ which $ 4 $ bits)

$ Rightarrow 4 $ comparisons

Leave $ k = $ 16: (binary $ 10,000 which $ 5 $ bits)

$ Rightarrow 5 $ comparisons

I think you can see a pattern.


Any set number 2 h, 2 ^ h + 1, cdots, 2 ^ h + 1} – 2, 2 h + 1} – 1 } quad land quad h> 0 $ $, is $ h + $ 1 long pieces and therefore $ h + $ 1 comparison.


Then i think $ T_ {avg} (n) = T_ {worse} (n) = n in O (n) $

But $ n $ is the number of bits of $ k $ number. Take function $ k $ as a parameter, no $ n $. So, my solution is not the desired one, I think.


In terms of $ k $ I think it would look like this:

$ T_ {worse} (k) = lfloor log_ {2} (2k) rfloor in O ( log k) $

$ T_ {avg} (k) = lfloor log_ {2} (2k) rfloor in O ( log k) $


Questions:

  1. It is the solution in terms of $ k $ Right?
  2. The solution in terms of $ n $: How would you rate that, personally? Know the task description of the above.

I have published a similar thread in the mathematical stack exchange, but I would like to get more opinions on this from the CS experts themselves.

python – Pyinstaller. Temporary files from the Datacompy package are not generated

I have made an application that uses Datacompy to compare two excel from the values ​​of a column. In the console it works perfect for me, but when doing the .exe with pyninstaller (pyinstaller Main.py –onefile) and when executing the program, I get the following console error:

Exception in Tkinter callback
Traceback (most recent call last):
    File "tkinter__init__.py", line 1705, in __call__
    File "Main.py", line 45, in search_file
    File "Main.py", line 66, in open_file_csv
    File "site-packagesdatacompycore.py", line 445, in report
    File "site-packagesdatacompycore.py", line 581, in render
FileNotFoundError: (Errno 2) No such file or directory:
'C:\Users\Usuario\AppData\Local\Temp\_MEI46562\datacompy\templates\header.txt'

Thank you!!

postgresql – Generating insert instructions for a table without creating any temporary tables

I can generate insert declarations for any table using the query

select 'INSERT INTO table values ('||id||', '''||currency||''')'
   from testone ; 

But I want to include a where condition in it. So, is it possible to include conditions between them or is there an alternative way to generate the insertion instructions for a table by adding some conditions between them and without the need for a temporary table?

shell: alternative to the temporary file in Bash

Some backup Blow The script on my machine copies the file names of specific directory entries into a text file.

Executing the script can gather existing names and find new ones, but then make sure that the names inserted in the backup file are sorted and unique.

local file=~/bar-entries.txt
touch "$file" "${file}_"
find ~/foo/bar -maxdepth 1 -type d ! -name bar | cat <"$file" - | sort | uniq > "${file}_"
mv "${file}_" "$file"

Can this code be optimized? As if wondering if some Blow build or an external command could allow you not to trust a temporary file and edit the file instead.

postgresql – How to design a unique table / index where uniqueness is temporary?

I have a table that records movies observed in a cinema:

CREATE TABLE cinema_movie_name (
  id integer DEFAULT nextval('cinema_movie_name_id_seq'::regclass) PRIMARY KEY,
  cinema_id integer NOT NULL REFERENCES cinema(id) ON DELETE CASCADE ON UPDATE RESTRICT,
  name text NOT NULL,
  movie_id integer REFERENCES movie(id) ON DELETE SET NULL ON UPDATE RESTRICT,
  created_at timestamp with time zone NOT NULL DEFAULT now()
);

Every time we see a new movie name in the cinema, we record it in this table and assign it to movie_id in our database.

The current singularity is applied in (cinema_id, name)that is to say

CREATE UNIQUE INDEX cinema_movie_name_cinema_id_name_idx ON cinema_movie_name(cinema_id, name);

The problem is that for a long time, there may be several different movies with the same name, that is, after an arbitrary length of time (id, cinema_id, name, movie_id) It becomes invalid.

Therefore, I need to create an index that imposes a unique constraint on (cinema_id, name) Y created_at ± 3 months

How to create a unique index with a temporary column?

Upload the file to s3 directly from drupal 8 instead of using temporary storage

I have a file upload form in drupal 8 where I am loading 3 different assets and they can be about 2 GB or more in size.
I have the s3fs module enabled and configured correctly, but due to temporary storage, it takes me a long time to load it into the web server. First it is loaded in the "/ tmp" directory and then in "s3". I also modified the Apache configuration to handle large file uploads.

Is there any way to speed up this charging process?
If possible, how to get the properties of the loaded file to edit the action in the same form?

dynamic: activation of the update of an InputField that has {Temporary, update function}

I have a DynamicModule that contains several InputFields and a button to cause recalculation. The calculation takes a while, so I am using the dynamic formulation [varname, {temporary, updatefunction}]. But if I have the cursor in a field that I have edited, and then I click on the recalculate button, the recalculation is performed without the updated version of varname. What can I add to the button code to induce the update, regardless of the field in which the cursor is located? For example, is there a way to simulate putting a tab key in the input sequence, which would cause the cursor to leave the current field and move on to the next one?

mysql: PHP PDO call procedure and shortly after selecting the temporary table

I have a procedure that creates a temporary table and I need to select it shortly after. I am using pdo and it always returns some error, in my last code the error 500 appears and I don't know where to go.

$proc = $this->conn->prepare("CALL proc_busca_disponivel(?)");
    $proc->bindParam(1, $id_evento, PDO::PARAM_INT, 4000);
    $proc->execute();
    $proc->closeCursor();

    $stmt = $this->conn->prepare("SELECT * from LISTA_DISPONIVEL");
    $stmt->execute();

    $res = $stmt->fetchAll(PDO::FETCH_ASSOC);

    var_dump($res);

It is not me who creates the database. If I execute the queries in the mysql panel, it returns perfectly, so I conclude that I am missing the point.
I also activated and deactivated the pdo buffers, as I had indicated it in the error in other attempts to create the code, but so far I have only passed error 500.

$this->conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); //ou false dá no mesmo