Otimizar velocidade do insert Mysql

Criei uma tabela para teste e adicionei um script que gera caracteres aleatoriamente e da um insert nos campos a,b e c. Para a realização de 1000 INSERTS levou o tempo de 36s e rodando o mesmo script porem sem gravar no banco o resultado foi de 3 segundos. consigo melhorar esse tempo de alguma forma?

Configuração:

Tipo de servidor: MariaDB
Sistema Operacional: Windows 7
RAM: 4G
Processador: Pentium E5700 3Ghz

Banco:

CREATE TABLE `teste` (   `id` int(11) NOT NULL,   `a` varchar(15) NOT NULL,   `b` varchar(15) NOT NULL,   `c` varchar(15) NOT NULL )  ALTER TABLE `teste`   ADD PRIMARY KEY (`id`); ALTER TABLE `teste`   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 

Find and insert tags using regex

I am converting a book from PDF to epub in calibre. But the titles are not inside header tags, hence trying a python function using regex to replace it.

example text:

<p class="calibre1"><a id="p1"></a>Chapter 370: Slamming straight on</p> <p class="softbreak"> </p> <p class="calibre1">Hearing Yan Zhaoge’s suggestion, the Jade Sea City martial practitioners here were all stunned.</p> <p class="calibre1"><a id="p7"></a>Chapter 372: Yan Zhaoge’s plan</p> <p class="softbreak"> </p> <p class="calibre1">Yan Zhaoge and Ah Hu sat on Pan-Pan’s back, black water swirling about Pan-Pan’s entire body, keeping away the seawater as he shot forward at lightning speed.</p> 

i tried using regex with

def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):      pattern = r"</a>(?i)chapter [0-9]+: [\w\s]+(.*)<br>"     list = re.findall(pattern, match.group())      for x in list:         x = "</a>(?i)chapter [0-9]+: [\w\s]+(.?)<br>"         x = s.split("</a>", 1)[0] + '</a><h2>' + s.split("a>",1)[1]         x = s.split("<br>", 1)[0] + '</h2><br>' + s.split("<br>",1)[1]     return match.group() 

and

 def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):     pattern = r"</a>(?i)chapter [0-9]+: [\w\s]+(.*)<br>"     s.replace(re.match(pattern, s), r'<h2>$  0') 

But still not getting expected result. what i want is…

Input

</a>Chapter 370: Slamming straight on</p>

Output

</a><h2>Chapter 370: Slamming straight on</h2></p>

h2 tag is to be added in all similar instances

Code to insert TAG taxonomy WordPress

I made a grave error. I delete many TAGs from the database of my blog.

Many TAGs were orphaned. And yet, unfortunately, many posts have anchor words that link to deleted tags.

That is, several links are broken and returning “Error 404 not found”.

This is affecting the indexing of my site.

I would like help!

Do I need an SQL code to insert the orphaned TAGs?

The code states:

  • check which tags exist in the posts and do not exist in the TAG table (database).

  • create (insert) the tags in the database table by filling in the fields: name and slug.

About the table structure:

The version of wordpress installed is: 5.2.1

MySql 5.0.12

Can someone help me ?

I await a return.

Sincerely,

Martin

Code to insert TAG taxonomy WordPress

I made a grave error. I delete many TAGs from the database of my blog.

Many TAGs were orphaned. And yet, unfortunately, many posts have anchor words that link to deleted tags.

That is, several links are broken and returning “Error 404 not found”.

This is affecting the indexing of my site.

I would like help!

Do I need an SQL code to insert the orphaned TAGs?

The code states:

  • check which tags exist in the posts and do not exist in the TAG table (database).

  • create (insert) the tags in the database table by filling in the fields: name and slug.

About the table structure:

The version of wordpress installed is: 5.2.1

MySql 5.0.12

Can someone help me ?

I await a return.

Sincerely,

Martin

Is there a way to insert Keyboard Glyphs in Google Docs?

Here on the StackExchange framework we have a nice feature, which is apparently called “Keyboard Glyphs” (cf. https://meta.stackexchange.com/questions/5527/keyboard-glyphs):

CTRL+Z

Is there a way (e.g. with an Add-On) to do the same in Google Docs? I browsed the Add-Ons but did not find anything, maybe it’s hidden somewhere different (e.g. in a Code Formatting Plugin).

WordPress MySQL Insert Statement not completing execution?

I am trying to debug my Dokan-Woocommerce-Wordpress project. For some reason, my insert statement isn’t being “completed”. As in, it seems like the $ wpdb object runs the query, but the results are not reflected in the database content. This is what my test plugin code looks like:

function save_term_john( $  post_id ) {     global $  wpdb;      $  post_id = 380;     $  tid = 200;      $  sql = "SELECT 1 AS found FROM {$  wpdb->prefix}term_relationships WHERE object_id = ".intval($  post_id)." AND term_taxonomy_id = ".intval($  tid);     $  results = $  wpdb->query($  sql);     if($  results)     {         $  sql = "UPDATE {$  wpdb->prefix}term_relationships SET term_taxonomy_id = ".intval($  tid)." WHERE object_id = ".intval($  post_id)." AND term_taxonomy_id = ".intval($  tid);     }     else     {         $  sql = "INSERT INTO {$  wpdb->prefix}term_relationships (object_id,term_taxonomy_id) SELECT ".intval($  post_id).",".intval($  tid);     }      $  wpdb->query($  sql);     file_put_contents("./testcall.txt",$  wpdb->last_query."\n\n",FILE_APPEND | LOCK_EX);     if($  wpdb->last_error)     {         die($  wpdb->last_error);     }  }  add_action( 'save_post', 'save_term_john' ); 

When I look in my database table wp_term_relationships, no record for object_id:380,taxonomy_term_id:200 appears.

My testcall.txt shows the following results

INSERT INTO wp_term_relationships (object_id,term_taxonomy_id) SELECT 380,200 /* From [/wp-content/plugins/john/john.php:228] */  UPDATE wp_term_relationships SET term_taxonomy_id = 200 WHERE object_id = 380 AND term_taxonomy_id = 200 /* From [john.com/dashboard/products/?product_id=380&action=edit&message=success] in [/wp-content/plugins/john/john.php:228] */ 

So according to my testcall.txt, my save_post hook was fired twice? And for whatever reason, my insert statement was not “completed”?

When I take these same queries from my testcall.txt and run them directly against, the database, everything worked fine.

What am I doing wrong? Why won’t the save_term_john save a record to the database?

insert different block in the middle of block content

I have a phtml for a block like this :

app/code/Vendor/Modul/view/frontend/templates/main.phtml

<div class="business-container">   <nav class="mini-head">   </nav>   <div class="main-content">     <div class="right-section">     </div>     <div class="left-section">         <!-- Dynamic phtml Content  -->     </div>   </div> </div> 

I want to use above phtml in 2 different pages, but for the left-section div class it will have different phtml content , is it possible to do this?

Подготовка команды INSERT

Хочу уточнить реализацию. Можно ли проще? В данный момент смущает, что я туда-сюда гоняю массив.

Нужно подготовить команду INSERT. Делаю так:

private OleDbCommand Command; readonly string INSERT = "INSERT INTO `{0}`({1}) VALUES({2})";  private string Join(string[] array, string separator=",") {     return String.Join(separator, array); }  private string[] AddQuotation(string[] array, string type="\"") {     for(int i = 0; i < array.Length; i++)     {         array[i] = String.Format("{0}{1}{0}", type, array[i]);     }      return array; }  public void Insert(string table, string[] column, string[] value) {     Command.CommandText = String.Format(INSERT, table,                                          Join(AddQuotation(column, "`")),                                          Join(AddQuotation(value)));     Command.ExecuteScalar(); }